<br><font size=2 face="sans-serif">Hi,</font>
<br><font size=2 face="sans-serif">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".</font>
<br><font size=2 face="sans-serif">I tested by inserting this line in the head of IPOPT.F :</font>
<br>
<br><font size=2 color=blue face="Courier New"><b>write</b></font><font size=2 face="Courier New">(line,*) 'Test'</font>
<br>
<br><font size=2 face="sans-serif">which gives the funny error:</font>
<br><font size=2 face="sans-serif">First-chance exception at 0x01d37ff5 (Ipopt.dll) in matlab.exe: 0xC0000005: </font>
<br><font size=2 face="sans-serif">Access violation reading location 0x00000000.</font>
<br>
<br><font size=2 face="sans-serif">//Jens</font>
<br>
<br>
<br><font size=1 color=white face="Arial">Message from Andreas Waechter <andreasw@watson.ibm.com> received on 2005-06-20 17:18</font>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif">2005-06-20 17:18</font>
<br>
<br>
<td>
<td><font size=1 face="sans-serif"><b>Andreas Waechter <andreasw@watson.ibm.com></b></font>
<br>
<br></table>
<br>
<table width=100%>
<tr valign=top>
<td>
<div align=center>
<br></div>
<td><font size=1 face="sans-serif"> To: Jens Pettersson/SECRC/ABB@ABB_SECRC</font>
<br><font size=1 face="sans-serif"> cc: hauan@cmu.edu, <Claas.Michalik@rwth-aachen.de>, <coin-ipopt@list.coin-or.org></font>
<br><font size=1 face="sans-serif"> Subject: Re: WG: [Coin-ipopt] Matlab interface</font></table>
<br>
<br>
<br><font size=2 face="Courier New">Hi<br>
<br>
At some earlier point, a colleague had written a MEX interface for Ipopt<br>
(years back...) and we ran into the same problem.<br>
<br>
If I remember correctly, the problem is that under Windows the MEX<br>
"executable" cannot write to standard output directly. Instead some<br>
Matlab-provided function must be used (something like mexPrintf?).<br>
<br>
Because of those problems, all output of Ipopt to standard out is directed<br>
through the subroutine "C_OUT" (see COIN/Ipopt/IPOPT/ipopt/c_out.f). In<br>
principle, the only change necessary to fix the problem you describe, all<br>
that has to be done is to replace the line containing "WRITE(*,8000)" by<br>
some appropriate call to a Matlab function.<br>
<br>
Since mexPrintf expects a C-style string, this probably has to go through<br>
a C-wrapper function, i.e., instead of those "WRITE(*,8000)" statement a C<br>
function is called that then transfers the Fortran-style string (without<br>
'\0') to a C-style string (adding '\n\0' at the end, after copying!!!) and<br>
then calling mexPrintf from C. Here, the lines with WRITE(*,8000) only in<br>
them (no LINES argument) are responsible for printing empty lines.<br>
<br>
I hope that all output to files is still working, so that it is really<br>
only C_OUT that has to be adapted.<br>
<br>
Andreas<br>
<br>
On Mon, 20 Jun 2005 jens.pettersson@se.abb.com wrote:<br>
<br>
> Hi Steinar,<br>
> to cut a long story short:<br>
><br>
> I managed to compile and create a mex-Dll using MSVC .NET and your files.<br>
> It is also possible to call this dll from Matlab but for some reasons it<br>
> crashes in the Ipopt-dll.<br>
> I debugged to find the error and it seams that the crash occurs when the<br>
> first "write" commando is excecuted. I tested by manually comment away the<br>
> write commando whcih caused the latest crash but then it only crashed on<br>
> the next one, etc.<br>
><br>
> Is there any one who knows why the seemingly inocent write- comando in<br>
> Fortran does not work with mex-files??<br>
><br>
> Also, I mean that the code is full with "write":s so there is not point in<br>
> commenting away all af them.... ??<br>
><br>
> //Jens<br>
><br>
<br>
</font>
<br>
<br>