Fortran 소스 MEX 파일
MEX 파일을 사용하면 MATLAB에서 Fortran 서브루틴을 호출할 수 있습니다. MEX 파일을 생성하기 위한 전제 조건은 다음과 같습니다.
Fortran 소스 코드를 작성할 수 있어야 함. MATLAB 편집기에서 이러한 파일을 생성할 수 있습니다.
MATLAB에서 지원하는 컴파일러. 지원되는 컴파일러의 최신 목록을 보려면 지원 및 호환되는 컴파일러를 참조하십시오.
Fortran Matrix API 함수와 Fortran MEX API 함수.
mex
빌드 스크립트. 자세한 내용은 실행 가능한 Fortran MEX 파일 항목을 참조하십시오.
예제는 MEX 함수의 소스 코드 예제 표 항목을 참조하십시오.
Fortran 코드를 사용하여 S-Function을 작성하는 방법에 대한 자세한 내용은 Simulink® 도움말 문서를 참조하십시오.
일부 애플리케이션에는 MEX 파일이 적합하지 않습니다. MATLAB은 Fortran과 같은 컴파일된 언어에서 시간이 많이 소요되는 로우 레벨의 프로그래밍 작업을 줄여주는 생산성 높은 환경입니다. 일반적으로는 MATLAB에서 프로그래밍을 수행하십시오. 애플리케이션에 필요한 경우가 아니면 MEX 파일을 사용하지 마십시오.
도움말 항목
- Fortran 소스 MEX 파일 만들기
이 예제에서는 MATLAB 행렬을 사용하여 MATLAB에서 Fortran 서브루틴
timestwo
를 호출하는 MEX 파일을 작성하는 방법을 보여줍니다. - Handle Complex Fortran Data
This example shows how to pass complex data to a MEX file using the interleaved complex Fortran Matrix API.
- Pass Separate Complex Numbers to Fortran Functions
Write MEX functions in MATLAB R2017b and earlier to call LAPACK or BLAS functions.
- User Messages
To print text in the MATLAB Command Window, use the
mexPrintf
function. - Error Handling
The
mexErrMsgIdAndTxt
function prints error information and terminates your binary MEX file. - Components of Fortran MEX File
The gateway routine is the entry point to the MEX file.
- MATLAB Fortran API Libraries
The Fortran Matrix API and the Fortran MEX API describe functions you can use in your gateway and computational routines that interact with MATLAB programs and the data in the MATLAB workspace.
- Data Flow in Fortran MEX Files
Suppose that your MEX file
myFunction
has two input arguments and one output argument. - Handling Large mxArrays
Binary MEX files built on 64-bit platforms can handle 64-bit
mxArray
s. - Upgrade Fortran MEX Files to use 64-bit API
Upgrade Fortran MEX files to use 64-bit API.