Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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 <allnor@tele.ntnu.no> wrote in message <60ac2150-8abc-4a44-bd15-8f0b963895e2@l31g2000vbp.googlegroups.com>...
> On 8 Okt, 16:37, "Michele Catalano" <cata...@yahoo.it> 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/engopts.sh 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?

Michele



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.