error #5149: Illegal character in statement label field with matlab2016b

4 visualizaciones (últimos 30 días)
Prasanna
Prasanna el 9 de Mzo. de 2018
Respondida: sanidhyak el 11 de Mayo de 2025
I am trying to compile a fortran mex file which is associated with a matlab code. I ran the command ‘mex FileName.f90’ on Matlab 16b and it gave me the “error #5149: Illegal character in statement label field”. I am using Matlab 16b and Intel Parallel Studio XE 2016 for Fortran with Microsoft Visual Studio 2013. I tried to remove the /fixed from mexopts folder as suggested by several posts but still get the same error. Can someone help me to solve the issue? I am quite new to programming. Thank you Prasanna

Respuestas (1)

sanidhyak
sanidhyak el 11 de Mayo de 2025
I understand that you are encountering a Fortran compiler error while attempting to compile a .f90 MEX file in MATLAB R2016b using Intel Parallel Studio XE 2016 and Microsoft Visual Studio 2013. This issue commonly arises when the Intel Fortran compiler interprets .f90 files as fixed-form Fortran, which expects strict formatting rules, even though .f90 files typically use free-form syntax.
To resolve this, you will need to explicitly instruct the compiler to use free-form syntax by passing the -free flag. Kindly refer to the following command that can be executed directly in MATLAB:
mex('-v', 'FileName.f90', 'FCFLAGS=$FCFLAGS -free')
This ensures that the .f90 file is compiled correctly using modern Fortran formatting.
Alternatively, you can create or modify a mexopts configuration file by running mex -setup FORTRAN and editing the relevant line in the generated .bat file from:
set FCFLAGS=/c /nologo /MD
to:
set FCFLAGS=/c /nologo /MD /free
This change will apply the /free flag every time you compile a Fortran MEX file, avoiding the error going forward.
For more details, you may refer to the following official documentations below:
I hope this helps!

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by