<html>
<head>
</head>
<body class='hmmessage'><div dir='ltr'>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
<div dir="ltr">Hello, I am trying to run the example code <br><br>
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
<p style="margin-bottom: 0in;">~/petsc-3.2-p7/src/ksp/ksp/examples/tutorials/ex50.c</p><p style="margin-bottom: 0in;"><br></p><p style="margin-bottom: 0in;">I changed the extension .c to .cpp and used g++ compiler.<br></p><p style="margin-bottom: 0in;"><br></p><p style="margin-bottom: 0in;">But, there were some errors when I compiled the code:</p><p style="margin-bottom: 0in"><br>
</p>
<p style="margin-bottom: 0in">ex50.cpp:58: error: cannot convert
‘PetscInt*’ to ‘PetscLogStage*’ for argument ‘2’ to
‘PetscErrorCode PetscLogStageRegister(const char*,
PetscLogStage*)’
</p>
<p style="margin-bottom: 0in">ex50.cpp:59: error: cannot convert
‘PetscInt*’ to ‘PetscLogStage*’ for argument ‘2’ to
‘PetscErrorCode PetscLogStageRegister(const char*, PetscLogStage*)’</p>
<p style="margin-bottom: 0in"><br>
</p>
<p style="margin-bottom: 0in"><br>
</p>
<p style="margin-bottom: 0in">ex50.cpp:326: error: cannot convert
‘PetscInt*’ to ‘int*’ for argument ‘3’ to ‘int
MPI_Get_count(MPI_Status*, MPI_Datatype, int*)’
</p>
<p style="margin-bottom: 0in">270
</p>
<p style="margin-bottom: 0in"><br>
</p>
<p style="margin-bottom: 0in">326 ierr = MPI_Get_count(&status,
MPIU_SCALAR, &inn); CHKERRQ(ierr);
</p>
<p style="margin-bottom: 0in">327 nn = inn;
</p>
<p style="margin-bottom: 0in"><br>
</p>
After I made the following modifications, the code was compiled successfully:<br><br>1 Change the data type of state[3] from PetscInt to PetscLogStage in line 49;<br>PetscLogStage stages[3];<br><br>2 Define a new variable inn as datatype of int in line 270;<br><br>3 Change the line 326 to: <br> ierr = MPI_Get_count(&status, MPIU_SCALAR, &inn); CHKERRQ(ierr); <br><br>4 After line 326, add: <br> nn = inn;<br><br><br>I am wondering if the modification by me is correct and are the bugs of the example code?<br>The version of PETSc I am using is 3.2-p7, the compiler is MPI plus g++. Is it because I use a c++ compiler for a c code? Thanks.<span><h1 id="word_name_h1"><br></h1></span></div>
</div></body>
</html>