Fortran and Matlab

david.sallngc.com
July 2, 2009 9:08 AM PDT
Rate
 
#3
Quoting - nabeels
Hello everybody
Can I anyone tell me how easy to call Fortran by Matlab?
What does intel suppose to send you when you purchase the license? (CDs, manuals, ...)

I do it all the time and it works great.  You need to learn how to write a mexfunction subroutine.  This is the interface between the Matlab and Fortran environment.  The mexfunction is written in Fortran.  You compile in the Matlab command window using the "mex" command.  You first need to setup a mexopts.bat file by invoking the command

> mex -setup

and follow the instructions.  If you are using Fortran 90 free-format, you will need to modify the mexopts.bat by removing the /FIXED qualifier (not sure why Mathworks put this in by default).

The most difficult part is writing the mexfunction subroutine using the Matlab MX functions (see the HELP -> MATLAB -> C and Fortran API Reference).  After years of writing these files, my advice is to make individual subroutines to perform certain functions.  You will use these over and over again.

You can also debug your mexfunction using Microsoft Visual Studio.  Mathworks has documentation on how to do this.  It is very cool how it all works.

There is a big learning curve here but it is well worth the time.  You can turn slow running Matlab code into fast running code.  You can also use OpenMP within the Fortran code and it will really fly!

Have fun!

Sincerely,

David

Intel Software Network Forums Statistics

8491 users have contributed to 31629 threads and 100769 posts to date.
In the past 24 hours, we have 28 new thread(s) 129 new posts(s), and 184 new user(s).

In the past 3 days, the most popular thread for everyone has been Implicite multithreading ??? The most posts were made to Crash when loading skeleton The post with the most views is Dear Steve, excuse me for a d

Please welcome our newest member shadowwolf99