Hi, Sawsan,I could build your code and I also could gdb it.$ gdb ./GW.exe...$ Thread 1 "GW.exe" received signal SIGSEGV, Segmentation fault.0x00007ffff1e6d44f in vecgetarray_ (x=0x7fffffffa718, fa=0x0, ia=0x7fffffffa75c, ierr=0x0) at /scratch/jczhang/petsc/src/vec/vec/interface/ftn-custom/zvectorf.c:257
257 *ierr = VecGetArray(*x, &lx);
(gdb) bt
#0 0x00007ffff1e6d44f in vecgetarray_ (x=0x7fffffffa718, fa=0x0, ia=0x7fffffffa75c, ierr=0x0) at /scratch/jczhang/petsc/src/vec/vec/interface/ftn-custom/zvectorf.c:257
#1 0x000000000040b6e3 in gw_solver (t_s=1.40129846e-45, n=300) at GW_solver_try.F90:169
#2 0x000000000040c6a8 in test_gw () at test_main.F90:35ierr=0x0 caused the segfault. See https://petsc.org/release/manualpages/Vec/VecGetArray/#vecgetarray, you should use VecGetArrayF90 instead.BTW, Barry, the code https://github.com/sshatanawi/SS_GWM/blob/main/GW_solver_try.F90#L169 has "call VecGetArray(temp_solution, H_vector, ierr)". I don't find petsc Fortran examples doing VecGetArray. Do we still support it?--Junchao ZhangOn Wed, Jan 10, 2024 at 2:38 PM Shatanawi, Sawsan Muhammad via petsc-users <petsc-users@mcs.anl.gov> wrote:Hello all,
I hope you are doing well.
Generally, I use gdb <the name of my exe.file> to debug the code.I got the attached error message.
I have tried to add the flag -start_in_debugger in the make file, but it didn't work, so it seems I was doing it in the wrong way
This is the link for the whole code: sshatanawi/SS_GWM (github.com)
Contribute to sshatanawi/SS_GWM development by creating an account on GitHub.
You can read the description of the code in " Model Desprciption.pdf"the compiling file is makefile_f90 where you can find the linked code files
I really appreciate your help
Bests,
Sawsan
From: Mark Adams <mfadams@lbl.gov>
Sent: Friday, January 5, 2024 4:53 AM
To: Shatanawi, Sawsan Muhammad <sawsan.shatanawi@wsu.edu>
Cc: Matthew Knepley <knepley@gmail.com>; 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]
This is a segv. As Matt said, you need to use a debugger for this or add print statements to narrow down the place where this happens.
You will need to learn how to use debuggers to do your project so you might as well start now.
If you have a machine with a GUI debugger that is easier but command line debuggers are good to learn anyway.
I tend to run debuggers directly (eg, lldb ./a.out -- program-args ...) and use a GUI debugger (eg, Totalview or DDT) if available.
Mark
On Wed, Dec 20, 2023 at 10:02 PM Shatanawi, Sawsan Muhammad via petsc-users <petsc-users@mcs.anl.gov> wrote:
Hello Matthew,
Thank you for your help. I am sorry that I keep coming back with my error messages, but I reached a point that I don't know how to fix them, and I don't understand them easily.
The list of errors is getting shorter, now I am getting the attached error messages
Thank you again,
Sawsan
From: Matthew Knepley <knepley@gmail.com>
Sent: Wednesday, December 20, 2023 6:54 PM
To: Shatanawi, Sawsan Muhammad <sawsan.shatanawi@wsu.edu>
Cc: Barry Smith <bsmith@petsc.dev>; 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]
On Wed, Dec 20, 2023 at 9:49 PM Shatanawi, Sawsan Muhammad via petsc-users <petsc-users@mcs.anl.gov> wrote:
Hello Barry,
Thank you a lot for your help, Now I am getting the attached error message.
Do not destroy the PC from KSPGetPC()
THanks,
MattBests,
Sawsan
From: Barry Smith <bsmith@petsc.dev>
Sent: Wednesday, December 20, 2023 6:32 PM
To: Shatanawi, Sawsan Muhammad <sawsan.shatanawi@wsu.edu>
Cc: Mark Adams <mfadams@lbl.gov>; 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]
Instead of
call PCCreate(PETSC_COMM_WORLD, pc, ierr)call PCSetType(pc, PCILU,ierr) ! Choose a preconditioner type (ILU)call KSPSetPC(ksp, pc,ierr) ! Associate the preconditioner with the KSP solver
do
call KSPGetPC(ksp,pc,ierr)call PCSetType(pc, PCILU,ierr)
Do not call KSPSetUp(). It will be taken care of automatically during the solve
On Dec 20, 2023, at 8:52 PM, Shatanawi, Sawsan Muhammad via petsc-users <petsc-users@mcs.anl.gov> wrote:
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 <mfadams@lbl.gov>
Sent: Wednesday, December 20, 2023 6:44 AM
To: Shatanawi, Sawsan Muhammad <sawsan.shatanawi@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<Matrix_RHS.F90><out.txt><solver.F90>[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.shatanawi@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
--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener