The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: mex - matlab calls fortran which calls matlab which calls fortran - is it possible?
Replies: 12   Last Post: Oct 15, 2009 9:17 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Michele Catalano

Posts: 10
Registered: 10/2/09
Re: mex - matlab calls fortran which calls matlab which calls fortran
Posted: Oct 8, 2009 10:57 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Rune Allnor <> wrote in message <>...
> On 8 Okt, 16:37, "Michele Catalano" <> wrote:
> > Dear All,
> >
> > I'm trying to link matlab and fortran with mex files and engine matlab, in linux OS. My general purpose is the following:
> >
> > 1) a matlab script A calls a mex function B based upon fortran source code
> >
> > 2) mex function B calls another function in matlab C within matlab engine
> >
> > 3) matlab routine C calls another mex file in fortran D
> >
> > While i'm able to do steps 2) and 3), I can't do step 1). Before to show the code, please reply to this simple question:
> >
> > Is it possible to build the overall process 1-3?

> I don't know if it is possible to do *all* of the above,
> but step 1) is trivial when the MEX function is 'simple'.
> And works correctly.
> To investigate what is going on, make some trivial functions
> A - D above, that only print some messages to the command line,
> like "Entering A - Calling B" at the entry point, and
> "Returned from B - Exiting A" as the last statement before
> return.
> This way you isolate the linking process from any problems
> caused by the business code. If you can get such a simple
> example to behave as expected, then the overall idea works.
> Apart from that, please post any error messages that appeared
> when you tried to compile the program.
> Rune

Thanks Rune,

It follows the command and the error:

mex '-f' /home/catalanom/Scrivania/provaF/ FortranChiamaMatlabSubII.F90
/usr/lib/gcc/i486-linux-gnu/4.2.4/libgfortranbegin.a(fmain.o): In function `main':
(.text+0x23): undefined reference to `MAIN__'
collect2: ld returned 1 exit status

mex: link of 'FortranChiamaMatlabSubII' failed.

??? Error using ==> mex
Unable to complete successfully

It seems it asks a main program for the function A, while I have to set it as a subroutine mexfunction()

Why i get this error?


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.