[petsc-users] Null Pointer Issue (Eigen-Value-Problem with user input Matrices)
maitri ksh
maitri.ksh at gmail.com
Tue Jul 25 17:06:39 CDT 2023
I am using the following setup:
1. petsc-3.19.3 (on wsl-ubuntu22.04 platform)
2. MATLAB-R2022a
3. slepc-3.19.1
4. configured using: './configure --with-cc=gcc --with-cxx=g++
--with-fc=gfortran --download-mpich --download-fblaslapack --with-matlab
--with-matlab-dir=/usr/local/MATLAB/R2022a --download-hdf5 --with-hdf5=1'
I am trying to solve an eigenvalue problem with user input matrices
'A.petsc' & 'B.petsc' using '*solveEigValProb.c*', there was no issue
during compiling but when I try to run the executable it produces error ('
*ERROR.txt*') indicating a null pointer issue but I am not sure what the
issue is.
Maitri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230726/721804ce/attachment-0001.html>
-------------- next part --------------
#include <petsc.h>
#include <petscviewer.h>
#include <slepceps.h>
int main(int argc, char **argv)
{
PetscInitialize(&argc, &argv, NULL, NULL);
/*PetscViewer viewer;*/
Mat A, B;
EPS eps;
MPI_Comm comm = PETSC_COMM_WORLD;
PetscInt nev = 2; // Number of eigenvalues to compute
PetscScalar sigma = 0.0; // Shift value
MatCreate(comm, &A);
PetscObjectSetName((PetscObject)A, "A");
/* open file for reading */
PetscViewer viewerA;
PetscErrorCode ierr;
ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, "A.petsc", FILE_MODE_READ, &viewerA);CHKERRQ(ierr);
ierr = MatLoad(A, viewerA);CHKERRQ(ierr);
PetscViewerDestroy(&viewerA);
/* open file for reading */
PetscViewer viewerB;
ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, "B.petsc", FILE_MODE_READ, &viewerB);CHKERRQ(ierr);
ierr = MatLoad(B, viewerB);CHKERRQ(ierr);
PetscViewerDestroy(&viewerB);
/* ... use matrices in computation ... */
// Create the eigensolver context
ierr = EPSCreate(PETSC_COMM_WORLD, &eps); CHKERRQ(ierr);
// Set operators A and B
ierr = EPSSetOperators(eps, A, B); CHKERRQ(ierr);
// Set dimensions and target (if needed)
ierr = EPSSetDimensions(eps, PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE); CHKERRQ(ierr);
ierr = EPSSetTarget(eps, sigma); CHKERRQ(ierr);
// Solve the eigenvalue problem
ierr = EPSSolve(eps); CHKERRQ(ierr);
// Get the number of computed eigenvalues
ierr = EPSGetConverged(eps, &nev); CHKERRQ(ierr);
// Get the computed eigenvalues and eigenvectors
PetscScalar eigenvalue, kr;
Vec eigenvector;
Vec xr, xi;
PetscPrintf(PETSC_COMM_WORLD, "Eigenvalues:\n");
for (PetscInt i = 0; i < nev; i++)
{
ierr = EPSGetEigenpair(eps, i, &eigenvalue, &kr, xr, xi); CHKERRQ(ierr);
PetscPrintf(PETSC_COMM_WORLD, "Eigenvalue %d: %.8f + %.8fi\n", i, PetscRealPart(eigenvalue), PetscImaginaryPart(eigenvalue));
}
// Destroy everything
ierr = EPSDestroy(&eps); CHKERRQ(ierr);
ierr = MatDestroy(&A); CHKERRQ(ierr);
ierr = MatDestroy(&B); CHKERRQ(ierr);
PetscFinalize();
return 0;
}
-------------- next part --------------
maitri at LAPTOP-0CP4FI1T:~/my_executables$ ./new2
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: Null argument, when expecting valid pointer
[0]PETSC ERROR: Null Pointer: Parameter # 1
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.19.3, unknown
[0]PETSC ERROR: ./new2 on a arch-linux-c-debug named LAPTOP-0CP4FI1T by maitri Wed Jul 26 00:54:45 2023
[0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich --download-fblaslapack --with-matlab --with-matlab-dir=/usr/local/MATLAB/R2022a --download-hdf5 --with-hdf5=1
[0]PETSC ERROR: #1 MatLoad() at /home/maitri/petsc/src/mat/interface/matrix.c:1317
[0]PETSC ERROR: #2 main() at new2.c:30
[0]PETSC ERROR: No PETSc Option Table entries
[0]PETSC ERROR: ----------------End of Error Message -------send entire error message to petsc-maint at mcs.anl.gov----------
application called MPI_Abort(MPI_COMM_SELF, 85) - process 0
[unset]: PMIU_write error; fd=-1 buf=:cmd=abort exitcode=85 message=application called MPI_Abort(MPI_COMM_SELF, 85) - process 0
:
system msg for write_line failure : Bad file descriptor
More information about the petsc-users
mailing list