La traduction de cette page n'est pas à jour. Cliquez ici pour voir la dernière version en anglais.
Fichiers MEX de source Fortran
Un fichier MEX permet d’appeler une sous-routine Fortran depuis MATLAB. Pour créer un fichier MEX, vous devez avoir :
La capacité d’écrire du code source Fortran. Vous pouvez créer ces fichiers avec MATLAB Editor.
Un compilateur supporté par MATLAB. Pour une liste à jour des compilateurs supportés, consultez Supported and Compatible Compilers (Compilateurs supportés et compatibles).
Les fonctions de Fortran Matrix API et de Fortran MEX API.
Le script de compilation
mex
. Pour plus d’informations, consultez Fichiers MEX Fortran exécutables.
Pour des exemples, consultez Tables of MEX Function Source Code Examples.
Pour plus d’informations sur l’écriture de S-functions avec du code Fortran, consultez votre documentation Simulink®.
Les fichiers MEX ne conviennent pas à toutes les applications. MATLAB est un environnement à haute productivité spécialement conçu pour éliminer les tâches chronophages de programmation de bas niveau dans les langages compilés comme Fortran. De manière générale, la programmation doit s’effectuer dans MATLAB. Utilisez des fichiers MEX seulement s’ils sont indispensables à votre application.
Rubriques
- 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 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.