Hello,
I don't think that I set preallocation values when I created the matrix, would 
you please have look at my code. It is just the petsc related part from my code.
I was able to fix some of the error messages. Now I have a new set of error 
messages related to the KSP solver (attached)

I appreciate your help​

Sawsan
________________________________
From: Mark Adams <mfad...@lbl.gov>
Sent: Wednesday, December 20, 2023 6:44 AM
To: Shatanawi, Sawsan Muhammad <sawsan.shatan...@wsu.edu>
Cc: petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov>
Subject: Re: [petsc-users] Help with Integrating PETSc into Fortran Groundwater 
Flow Simulation Code


[EXTERNAL EMAIL]

Did you set preallocation values when you created the matrix?
Don't do that.

On Wed, Dec 20, 2023 at 9:36 AM Shatanawi, Sawsan Muhammad 
<sawsan.shatan...@wsu.edu<mailto:sawsan.shatan...@wsu.edu>> wrote:
Hello,

I am trying to create a sparse matrix( which is as I believe a zero matrix) 
then adding some nonzero elements to it over a loop, then assembling it

Get Outlook for 
iOS<https://urldefense.com/v3/__https://aka.ms/o0ukef__;!!JmPEgBY0HMszNaDT!uUJ_jeYf45gcXDGR_PeMjhU7hbd_fKcXJPn0pM9eb-YQihKNYuXMYM9x-hglsbXsCFIwNBWgHXdetHODupsOloE$>
________________________________
From: Mark Adams <mfad...@lbl.gov<mailto:mfad...@lbl.gov>>
Sent: Wednesday, December 20, 2023 2:48 AM
To: Shatanawi, Sawsan Muhammad 
<sawsan.shatan...@wsu.edu<mailto:sawsan.shatan...@wsu.edu>>
Cc: petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov> 
<petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov>>
Subject: Re: [petsc-users] Help with Integrating PETSc into Fortran Groundwater 
Flow Simulation Code


[EXTERNAL EMAIL]

I am guessing that you are creating a matrix, adding to it, finalizing it 
("assembly"), and then adding to it again, which is fine, but you are adding 
new non-zeros to the sparsity pattern.
If this is what you want then you can tell the matrix to let you do that.
Otherwise you have a bug.

Mark

On Tue, Dec 19, 2023 at 9:50 PM Shatanawi, Sawsan Muhammad via petsc-users 
<petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov>> wrote:
Hello everyone,

I hope this email finds you well.

 My Name is Sawsan Shatanawi, and I am currently working on developing a 
Fortran code for simulating groundwater flow in a 3D system. The code involves 
solving a nonlinear system, and I have created the matrix to be solved using 
the PCG solver and Picard iteration. However, when I tried to assign it as a 
PETSc matrix I started getting a lot of error messages.

I am kindly asking if someone can help me, I would be happy to share my code 
with him/her.

Please find the attached file contains a list of errors I have gotten

Thank you in advance for your time and assistance.

Best regards,

 Sawsan

Attachment: Matrix_RHS.F90
Description: Matrix_RHS.F90

 5.2000000E-03
   50.00000
   10.00000
  0.0000000E+00
[0]PETSC ERROR: --------------------- Error Message 
--------------------------------------------------------------
[0]PETSC ERROR: Object is in wrong state
[0]PETSC ERROR: You requested a vector from a KSP that cannot provide one
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.20.0, Sep 28, 2023
[0]PETSC ERROR: ./GW.exe on a  named login-p2n02.kamiak.wsu.edu by 
sawsan.shatanawi Wed Dec 20 17:44:37 2023
[0]PETSC ERROR: Configure options 
--prefix=/opt/apps/petsc/3.20.0/intel/20.2/mpich/3.3.2 
--with-blaslapack-dir=/opt/apps/intel/20.2/compilers_and_libraries_2020.2.254/linux/mkl
 --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
[0]PETSC ERROR: #1 KSPCreateVecs() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/ksp/ksp/interface/iterativ.c:1785
[0]PETSC ERROR: #2 KSPSetWorkVecs() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/ksp/ksp/interface/iterativ.c:1853
[0]PETSC ERROR: #3 KSPSetUp_CG() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/ksp/ksp/impls/cg/cg.c:79
[0]PETSC ERROR: #4 KSPSetUp() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/ksp/ksp/interface/itfunc.c:377
[0]PETSC ERROR: --------------------- Error Message 
--------------------------------------------------------------
[0]PETSC ERROR:   It appears a new error in the code was triggered after a 
previous error, possibly because:
[0]PETSC ERROR:   -  The first error was not properly handled via (for example) 
the use of
[0]PETSC ERROR:      PetscCall(TheFunctionThatErrors()); or
[0]PETSC ERROR:   -  The second error was triggered while handling the first 
error.
[0]PETSC ERROR:   Above is the traceback for the previous unhandled error, 
below the traceback for the next error
[0]PETSC ERROR:   ALL ERRORS in the PETSc libraries are fatal, you should add 
the appropriate error checking to the code
[0]PETSC ERROR: Object is in wrong state
[0]PETSC ERROR: Mat object's type is not set: Argument # 1
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.20.0, Sep 28, 2023
[0]PETSC ERROR: ./GW.exe on a  named login-p2n02.kamiak.wsu.edu by 
sawsan.shatanawi Wed Dec 20 17:44:37 2023
[0]PETSC ERROR: Configure options 
--prefix=/opt/apps/petsc/3.20.0/intel/20.2/mpich/3.3.2 
--with-blaslapack-dir=/opt/apps/intel/20.2/compilers_and_libraries_2020.2.254/linux/mkl
 --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
[0]PETSC ERROR: #1 MatGetFactor() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/mat/interface/matrix.c:4766
[0]PETSC ERROR: #2 PCFactorSetUpMatSolverType_Factor() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/ksp/pc/impls/factor/factimpl.c:9
[0]PETSC ERROR: #3 PCFactorSetUpMatSolverType() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/ksp/pc/impls/factor/factor.c:105
[0]PETSC ERROR: #4 PCSetUp_ILU() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/ksp/pc/impls/factor/ilu/ilu.c:127
[0]PETSC ERROR: #5 PCSetUp() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/ksp/pc/interface/precon.c:1068
[0]PETSC ERROR: #6 KSPSetUp() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/ksp/ksp/interface/itfunc.c:415
[0]PETSC ERROR: #7 KSPSolve_Private() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/ksp/ksp/interface/itfunc.c:836
[0]PETSC ERROR: #8 KSPSolve() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/ksp/ksp/interface/itfunc.c:1082
[0]PETSC ERROR: --------------------- Error Message 
--------------------------------------------------------------
[0]PETSC ERROR:   It appears a new error in the code was triggered after a 
previous error, possibly because:
[0]PETSC ERROR:   -  The first error was not properly handled via (for example) 
the use of
[0]PETSC ERROR:      PetscCall(TheFunctionThatErrors()); or
[0]PETSC ERROR:   -  The second error was triggered while handling the first 
error.
[0]PETSC ERROR:   Above is the traceback for the previous unhandled error, 
below the traceback for the next error
[0]PETSC ERROR:   ALL ERRORS in the PETSc libraries are fatal, you should add 
the appropriate error checking to the code
[0]PETSC ERROR: Invalid pointer
[0]PETSC ERROR: Invalid Pointer to PetscObject: Argument 'w' (parameter # 1)
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.20.0, Sep 28, 2023
[0]PETSC ERROR: ./GW.exe on a  named login-p2n02.kamiak.wsu.edu by 
sawsan.shatanawi Wed Dec 20 17:44:37 2023
[0]PETSC ERROR: Configure options 
--prefix=/opt/apps/petsc/3.20.0/intel/20.2/mpich/3.3.2 
--with-blaslapack-dir=/opt/apps/intel/20.2/compilers_and_libraries_2020.2.254/linux/mkl
 --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
[0]PETSC ERROR: #1 VecWAXPYAsync_Private() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/vec/vec/interface/rvector.c:795
[0]PETSC ERROR: #2 VecWAXPY() at 
/weka/data/kamiak/rohit.dhariwal/software_installs/petsc/3.20.0/petsc-3.20.0/src/vec/vec/interface/rvector.c:853
./compile.sh: line 4: 13784 Segmentation fault      ./GW.exe

Attachment: solver.F90
Description: solver.F90

Reply via email to