Archivos MEX de fuente Fortran
Un archivo MEX permite llamar a una subrutina de Fortran desde MATLAB. Para crear un archivo MEX, se necesita lo siguiente:
La capacidad de escribir código fuente de Fortran. Es posible crear estos archivos con MATLAB Editor.
Un compilador compatible con MATLAB. Para obtener una lista actualizada de compiladores compatibles, consulte Compiladores compatibles.
Las funciones API para manipular matrices de Fortran y API MEX de Fortran.
El script de compilación
mex
. Para obtener más información, consulte Archivos MEX de Fortran ejecutables.
Para obtener ejemplos, consulte Tables of MEX Function Source Code Examples.
Para obtener información acerca de cómo escribir funciones S mediante el uso de código Fortran, consulte la documentación de Simulink®.
Los archivos MEX no son apropiados para todas las aplicaciones. MATLAB es un entorno de alta productividad que se especializa en eliminar programación de bajo nivel que requiere mucho tiempo en lenguajes compilados, como Fortran. En general, haga la programación en MATLAB. No utilice archivos MEX a menos que su aplicación lo requiera.
Temas
- Create Fortran Source MEX File
This example shows how to write a MEX file to call a Fortran subroutine,
timestwo
, in MATLAB using a MATLAB matrix. - 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 API para manipular matrices de Fortran and the API MEX de Fortran 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.