I figured this out a few minutes after posting my question by trying something I thought I had already tried: adding the -R2018a option. My guess is I had to both add -R2018a to the mex options and change the file extension to .F90, which I had probably tried individually but not simultaneously. I'll leave the question up in case someone has this same problem in the future when getting into using Fortran mex files.
Are Fortran mex files restricted to fixed format?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm learning to mex Fortran files and am having trouble with the timestwo.F tutorial. I'm able to compile and run the built-in, fixed format example file without a problem. However, when I tried to compile my own free format file named timestwo.f90, I got a bunch of errors about invalid preprocessor directives.
From a MATLAB Answers question, I found that I needed to capitalize the f in the file extension. mex timestwo.F90 completes successfully. When I try to use the function, though, I get an error:
Invalid MEX-file '/home/user/Documents/MATLAB/mex/timestwo.mexa64': /home/user/Documents/MATLAB/mex/timestwo.mexa64: undefined
symbol: mxgetdoubles_
The only difference between my file and the example file is that mine is free format and doesn't include the #if MX_HAS_INTERLEAVED_COMPLEX check found in the example file. Is this an issue with support for free format source?
0 Kommentare
Antworten (1)
Josh G.
am 28 Mär. 2019
2 Kommentare
James Tursa
am 3 Apr. 2019
Bearbeitet: James Tursa
am 3 Apr. 2019
The -R2018a option is related to whether you are using the old separate complex data format interface or the new interleaved complex data format interface. This has nothing to do with your fixed or free format source code problems.
In the past, the free format problem has been caused by MATLAB having a "/fixed" COMPFLAGS option in their build files, forcing the compilation to be fixed format regardless of extension. Alas, I just checked a Fortran build file for version R2018b WIN64 and this silly option is still there in spite of my repeated attempts at getting TMW to remove it. This may be the root cause of your fixed/free problems. The solution is to edit the build files (e.g., intel_fortran_18_vs2017.xml) and remove the "/fixed" option from the COMPFLAGS line. That will let the compiler choose fixed or free format based on file extension (.f or .f90 respectively) as it should be. I wouldn't think the compiler would care about upper/lower case for the extension, but maybe something in the MATLAB build scripts does.
@TMW, are you ever going to remove that "/fixed" option? It only causes problems!
Siehe auch
Kategorien
Mehr zu MATLAB Compiler finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!