MATLAB Answers

The future of FORTRAN mex?

14 views (last 30 days)
Robert
Robert on 28 Dec 2020
Commented: Robert on 27 Jan 2021
With Apple M1 now out, and hopefully future MATLAB releases will have native support. The next question is FORTRAN mex comiler support. Up to this point for both Windows and Mac, it was Intel only (though you could jump through hoops to get gfortran mex on the Mac). So MathWorks, coders want to know, what is next? How should we prepare? NAG has a native FORTRAN M1 version out, and there is some "betas" for gfotran for M1. I doubt Intel will put out a compiler for Apple M1. Should we start porting FORTRAN mex code to C?
  1 Comment
dpb
dpb on 28 Dec 2020
"Should we start porting FORTRAN mex code to C?"
Probably. TMW seems to have basically abandoned Fortran 10 years ago.
Combined with their incredibly arcane and absurd installation where they won't just give you the directions for compile/link steps,but try to force an "approved" compiler, I gave up entirely.
There's no excuse for such a nightmare; I had a legacy system to try to maintain, but they broke compatibility and then wouldn't let a .mex file load if the link wasn't with the specific version libraries even though there were no changes. Frustrating wasn't the word for the feelings I had...and support stock answer is "unsupported".
Then, too, trying to get them to tell you what may be in the future is futile as well.
Wish had better news...

Sign in to comment.

Answers (1)

Chris Rorden
Chris Rorden on 3 Jan 2021
Edited: Chris Rorden on 5 Jan 2021
An experimental build of the open source gFortran compiler is available for the M1
In my testing, it performs very well
A challenge for moving mathematical operations between architectures is how they handle not-a-number values. However, this will impact any compiler, Fortran or C. This is a reason that tools like R have been slow to convert:
The Fortran code in Matlab is robust and proven. Switching to C would not provide any performance benefit. The benefit of Fortran is well established, proven routines. The advantage of C is that it is more familiar to most contemporary programmers, which might help maintaining and extending code. However, conducting both a switch in architectures and a switch in languages at the same time seems to be a perilous choice. A better approach is to maintain the proven Fortran code for the new architecture, to help identify architecture specific issues.
  1 Comment
Robert
Robert on 27 Jan 2021
I understand we will have Fortran for AppleSilicon, the question is will MATLAB support Fortran mex on m1. A heads up from Mathworks for time to prepare would be nice. For this reason I decided to upgrade my 2016 with the 2020 Intel 13" macbook pro with 32GB instead of the M1 and will wait and see.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!