Notice! This document is currently in Archived status.
The content of this document may be incorrect or out dated.

Incorporating Fortran functions into Matlab

What is wrong with trying to use the .MEX method of incorporating Fortran functions into Matlab as subroutines?

The problem is that Mathworks does not load the libraries in a way that all symbols can be resolved.

Work around:

  1. Set environment variable LD_LIBRARY_PATH whenever running
    1. /usr/opt/bin/matlab (4.2c)
    2. /usr/opt/bin/fmex (4.2c)
    3. /usr/opt/bin/cmex (4.2c)
      1. csh and relatives setenv LD_LIBRARY_PATH /usr/opt/lib
      2. sh and relatives LD_LIBRARY_PATH=/usr/opt/lib export LD_LIBRARY_PATH

  2. /usr/opt/bin/fmex (4.2c). When compiling using fmex, you must force the linker to search the math library, /opt/SUNWspro/SC2.0.1/libm.a, twice in order to resolve all the symbols. The way to do this is to invoke fmex as follows: fmex func.f LD_FCLIBS='$LD_FCLIBS /opt/SUNWspro/SC2.0.1/libm.a

    [Note: The script fmex itself sets LD_FCLIBS = -lM77 -lF77 -lm before it appends the command line values.]

  3. /usr/opt/bin/cmex (4.2c). Probably needs to be done the same way as fmex. There is no test case.

Last modified: 2007/03/07 11:53:45.022000 US/Eastern by Unknown
Created: 2007/03/07 11:53:45.022000 US/Eastern by brian.r.brinegar.1.



Type in a few keywords describing what information you are looking for in the text box below.

Admin Options: Edit this Document