Hello, I am trying to run the example code 




        
        
        
        


~/petsc-3.2-p7/src/ksp/ksp/examples/tutorials/ex50.c
I changed the extension .c to .cpp and used g++ compiler.

But, there were some errors when I compiled the code:


ex50.cpp:58: error: cannot convert
?PetscInt*? to ?PetscLogStage*? for argument ?2? to
?PetscErrorCode PetscLogStageRegister(const char*,
PetscLogStage*)?

ex50.cpp:59: error: cannot convert
?PetscInt*? to ?PetscLogStage*? for argument ?2? to
?PetscErrorCode PetscLogStageRegister(const char*, PetscLogStage*)?






ex50.cpp:326: error: cannot convert
?PetscInt*? to ?int*? for argument ?3? to ?int
MPI_Get_count(MPI_Status*, MPI_Datatype, int*)?

270 




326       ierr = MPI_Get_count(&status,
MPIU_SCALAR, &inn); CHKERRQ(ierr);  

327     nn = inn;      





After I made the following modifications, the code was compiled successfully:

1 Change the data type of state[3] from PetscInt to PetscLogStage in line 49;
PetscLogStage stages[3];

2 Define a new variable inn as datatype of int in line 270;

3 Change the line 326 to: 
       ierr = MPI_Get_count(&status, MPIU_SCALAR, &inn); CHKERRQ(ierr);     

4 After line 326, add:   
      nn = inn;


I am wondering if the modification by me is correct and are  the bugs of the 
example code?
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.

                                          
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130416/a72915ca/attachment-0001.html>

Reply via email to