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