<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hello! I am new using Ipopt and have tested some example problems with c++ interface. I want to use MPI for solving in parallel multiple NLP, but when runnning with MPI I get an error message. My cpp main file is:<br><br><font style="font-size: 8pt;" size="1">#include "IpIpoptApplication.hpp"</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">#include "IpSolveStatistics.hpp"</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">#include "MyNLP.hpp"</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">#include "mpi.h"</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">#include <iostream></font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">using namespace Ipopt;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">using namespace std;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">int main(int argc, char** argv)</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">{</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> int size, rank;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> int i; double begin, end;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> ApplicationReturnStatus status;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> MPI_Init(&argc, &argv); </font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> MPI_Comm_size(MPI_COMM_WORLD, &size); </font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> MPI_Comm_rank(MPI_COMM_WORLD, &rank);</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> begin = MPI_Wtime();</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> if(rank == 0){</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> SmartPtr<IpoptApplication> app = IpoptApplicationFactory();</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> status = app->Initialize();</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> SmartPtr<TNLP> mynlp = new MyNLP();</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> status = app->OptimizeTNLP(mynlp);</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> }</font><font style="font-size: 8pt;" size="1"><br>else{<br><br> }<br></font><font style="font-size: 8pt;" size="1"> end = MPI_Wtime();</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> MPI_Finalize();</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> cout<< end-begin<<endl;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> return (int) status;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">}</font><br><br>I compiles fine with:<br><font style="font-size: 8pt;" size="1">mpic++ -O3 -o example example.cpp -I/home/max/CoinIpopt/build/include/coin -L/home/max/CoinIpopt/build/lib -lipopt -llapack -ldl -lcoinmumps -lblas -lgfortran -lm -lquadmath -lcoinhsl -lcoinmetis</font><font style="font-size: 8pt;" size="1"><br></font><br>and run with:<br><font style="font-size: 8pt;" size="1">mpirun -np 3 ./example<br><br><font style="font-size: 12pt;" size="3">but i get this message error<br><font style="font-size: 8pt;" size="1">*** The MPI_comm_size() function was called before MPI_INIT was invoked.</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">*** This is disallowed by the MPI standard.</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">*** Your MPI job will now abort.</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">[master:4655] Local abort before MPI_INIT completed successfully; not able to aggregate error messages, and not able to guarantee that all other processes were killed!</font><font style="font-size: 8pt;" size="1"><br></font><br>I am not sure why this error exists. It seems that using the ipopt linkers produce this error. Could you help me please?? Is there something wrong in the compilation step or how can I make ipopt run using MPI?</font></font><span id="result_box" class="short_text" lang="en"><span class="hps"><font style="font-size: 12pt;" size="3"> I</font>'ll be</span> <span class="hps">grateful for your help.<br>Thanks in advance <br>max<br></span></span> </div></body>
</html>