From: James Tursa on
"George " <guanjihou(a)gmail.com> wrote in message <hup30u$cio$1(a)fred.mathworks.com>...
>
> I have another question, which is a more general one. I am now writing a Fortran program, and I want to call a Matlab routine, which is a bunch of m files that perform certain computation functionality. After the Matlab routine finish the computation, there will be a lot of results sending back to Fortran, those results are stored in Matrix form. So my question is that what is the most efficient and convenient way to do this result sending back job? I know engGetVariable() can do this, but for so many results that need to be sent back, it would be a huge work.

The most efficient thing to do would be to convert the whole thing to a mex routine instead of an engine application. But if you really need the engine formulation, then there is nothing you can do to prevent the data copying going back & forth between your program and the engine. The only thing would be, now that you are aware of the data copy penalty, is to pay close attention to the data traffic with your engGetVariable and engPutVariable calls and try to minimize the number of calls and the size of the variables involved.

James Tursa