WG: [Coin-ipopt] Matlab interface

jens.pettersson at se.abb.com jens.pettersson at se.abb.com
Tue Jun 21 03:25:32 EDT 2005


Hi,
I dont think it is the C_out routine that causes the problems because when 
I debug the Ipopt.dll, it crashes on the first occurece of any "write".
I tested by inserting this line in the head of IPOPT.F :

write(line,*) 'Test'

which gives the funny error:
First-chance exception at 0x01d37ff5 (Ipopt.dll) in matlab.exe: 
0xC0000005: 
Access violation reading location 0x00000000.

//Jens


Message from Andreas Waechter <andreasw at watson.ibm.com> received on 
2005-06-20 17:18

2005-06-20 17:18



Andreas Waechter <andreasw at watson.ibm.com>





        To:     Jens Pettersson/SECRC/ABB at ABB_SECRC
        cc:     hauan at cmu.edu, <Claas.Michalik at rwth-aachen.de>, 
<coin-ipopt at list.coin-or.org>
        Subject:        Re: WG: [Coin-ipopt] Matlab interface


Hi

At some earlier point, a colleague had written a MEX interface for Ipopt
(years back...) and we ran into the same problem.

If I remember correctly, the problem is that under Windows the MEX
"executable" cannot write to standard output directly.  Instead some
Matlab-provided function must be used (something like mexPrintf?).

Because of those problems, all output of Ipopt to standard out is directed
through the subroutine "C_OUT" (see COIN/Ipopt/IPOPT/ipopt/c_out.f).  In
principle, the only change necessary to fix the problem you describe, all
that has to be done is to replace the line containing "WRITE(*,8000)" by
some appropriate call to a Matlab function.

Since mexPrintf expects a C-style string, this probably has to go through
a C-wrapper function, i.e., instead of those "WRITE(*,8000)" statement a C
function is called that then transfers the Fortran-style string (without
'\0') to a C-style string (adding '\n\0' at the end, after copying!!!) and
then calling mexPrintf from C.  Here, the lines with WRITE(*,8000) only in
them (no LINES argument) are responsible for printing empty lines.

I hope that all output to files is still working, so that it is really
only C_OUT that has to be adapted.

Andreas

On Mon, 20 Jun 2005 jens.pettersson at se.abb.com wrote:

> Hi Steinar,
>  to cut a long story short:
>
> I managed to compile and create a mex-Dll using MSVC .NET and your 
files.
> It is also possible to call this dll from Matlab but for some reasons it
> crashes in the Ipopt-dll.
> I debugged to find the error and it seams that the crash occurs when the
> first "write" commando is excecuted. I tested by manually comment away 
the
> write commando whcih caused the latest crash but then it only crashed on
> the next one, etc.
>
> Is there any one who knows why the seemingly inocent write- comando in
> Fortran does not work with mex-files??
>
> Also, I mean that the code is full with "write":s so there is not point 
in
> commenting away all af them.... ??
>
> //Jens
>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.coin-or.org/pipermail/ipopt/attachments/20050621/c4f8bebd/attachment-0045.html 


More information about the Coin-ipopt mailing list