C # calls a Fortran-generated DLL with insufficient memory for the method report

Source: Internet
Author: User

recently in the study of a program, the company gave, the program is written in VB, the program also has a computational model, written in Fortran language.

In debugging to this model inside the method times wrong, said is insufficient memory, so on the online search method, read two blog post after the problem solved.

C # and Fortran mixed programming local call FORTRAN dynamic link library

C # and Fortran mixed programming:http://www.iepi.com.cn/BBS_CN/forum.php?mod=viewthread&tid=62 &extra=page%3d1

The reason is the problem of stack release, I use C # test, and VB-like solution, error content

The FORTRAN code is as follows: The following green code allows methods to be called externally

INTEGER FUNCTION ADD (A, B)
! dec$ ATTRIBUTES Dllexport::add
INTEGER:: A, b
Add=a+b
END

According to a blog above, the Fortran language is cleared by the caller by default. Therefore, the stack purge method for both parties must be called uniformly. " Combined with your own understanding, in order to unify the way to clear the stack. I only modified the FORTRAN code, and then solved the problem.

The modified code is as follows:

INTEGER FUNCTION ADD (A, B)
! dec$ ATTRIBUTES Dllexport::add

! dec$ ATTRIBUTES stdcall,alias: ' Add ':: Add
INTEGER:: A, b
Add=a+b
END

C # calls a Fortran-generated DLL with insufficient memory for the method report

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.