<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">Hello Barry,<br>
<br>
Thank you a lot for your help, Now I am getting the attached error message.</span></div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);"><br>
</span></div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">Bests,<br>
Sawsan</span></div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Barry Smith <bsmith@petsc.dev><br>
<b>Sent:</b> Wednesday, December 20, 2023 6:32 PM<br>
<b>To:</b> Shatanawi, Sawsan Muhammad <sawsan.shatanawi@wsu.edu><br>
<b>Cc:</b> Mark Adams <mfadams@lbl.gov>; petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
<b>Subject:</b> Re: [petsc-users] Help with Integrating PETSc into Fortran Groundwater Flow Simulation Code</font>
<div> </div>
</div>
<div style="line-break:after-white-space">
<p style="border:1px; border-style:solid; border-color:#FFCACA; background-color:#FFEB9C; padding:1px">
<span style="font-size:10.0pt; color:black"><b>[EXTERNAL EMAIL]</span></b></p>
<div>
<div><br>
</div>
Instead of 
<div><br>
</div>
<div>
<div>    call PCCreate(PETSC_COMM_WORLD, pc, ierr)</div>
<div>    call PCSetType(pc, PCILU,ierr) ! Choose a preconditioner type (ILU)</div>
<div>    call KSPSetPC(ksp, pc,ierr)  ! Associate the preconditioner with the KSP solver</div>
<div><br>
</div>
<div>do</div>
<div><br>
</div>
<div>    call KSPGetPC(ksp,pc,ierr)</div>
<div>    call PCSetType(pc, PCILU,ierr)</div>
<div><br>
</div>
<div>Do not call KSPSetUp(). It will be taken care of automatically during the solve</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div><br>
<blockquote type="cite">
<div>On Dec 20, 2023, at 8:52 PM, Shatanawi, Sawsan Muhammad via petsc-users <petsc-users@mcs.anl.gov> wrote:</div>
<br class="x_Apple-interchange-newline">
<div>
<div class="x_elementToProof" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt">
Hello, <br>
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.<br>
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)<br>
<br>
I appreciate your help​</div>
<div class="x_elementToProof" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_elementToProof" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt">
Sawsan</div>
<div id="x_appendonsend" style="font-family:Helvetica; font-size:18px; font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
</div>
<hr tabindex="-1" style="font-family:Helvetica; font-size:18px; font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; text-decoration:none; display:inline-block; width:934.90625px">
<span style="font-family:Helvetica; font-size:18px; font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; float:none; display:inline!important"></span>
<div id="x_divRplyFwdMsg" dir="ltr" style="font-family:Helvetica; font-size:18px; font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_Apple-converted-space"> </span>Mark Adams <<a href="mailto:mfadams@lbl.gov">mfadams@lbl.gov</a>><br>
<b>Sent:</b><span class="x_Apple-converted-space"> </span>Wednesday, December 20, 2023 6:44 AM<br>
<b>To:</b><span class="x_Apple-converted-space"> </span>Shatanawi, Sawsan Muhammad <<a href="mailto:sawsan.shatanawi@wsu.edu">sawsan.shatanawi@wsu.edu</a>><br>
<b>Cc:</b><span class="x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a><span class="x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_Apple-converted-space"> </span>Re: [petsc-users] Help with Integrating PETSc into Fortran Groundwater Flow Simulation Code</font>
<div> </div>
</div>
<div style="font-family:Helvetica; font-size:18px; font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<div style="margin-top:0px; margin-bottom:0px; border:1px solid rgb(255,202,202); background-color:rgb(255,235,156); padding:1px">
<span style="font-size:10pt"><b>[EXTERNAL EMAIL]</b></span></div>
<div>
<div dir="ltr">Did you set preallocation values when you created the matrix?
<div>Don't do that.</div>
</div>
<br>
<div class="x_x_gmail_quote">
<div dir="ltr" class="x_x_gmail_attr">On Wed, Dec 20, 2023 at 9:36 AM Shatanawi, Sawsan Muhammad <<a href="mailto:sawsan.shatanawi@wsu.edu">sawsan.shatanawi@wsu.edu</a>> wrote:<br>
</div>
<blockquote class="x_x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left-width:1px; border-left-style:solid; border-left-color:rgb(204,204,204); padding-left:1ex">
<div>
<div dir="ltr">
<div dir="ltr">Hello, </div>
<div dir="ltr"><br>
</div>
<div dir="ltr">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 </div>
<div id="x_x_m_-677654408871201876ms-outlook-mobile-signature">
<div><br>
</div>
Get<span class="x_Apple-converted-space"> </span><a href="https://urldefense.com/v3/__https://aka.ms/o0ukef__;!!JmPEgBY0HMszNaDT!uUJ_jeYf45gcXDGR_PeMjhU7hbd_fKcXJPn0pM9eb-YQihKNYuXMYM9x-hglsbXsCFIwNBWgHXdetHODupsOloE$" originalsrc="https://urldefense.com/v3/__https://aka.ms/o0ukef__;!!JmPEgBY0HMszNaDT!uUJ_jeYf45gcXDGR_PeMjhU7hbd_fKcXJPn0pM9eb-YQihKNYuXMYM9x-hglsbXsCFIwNBWgHXdetHODupsOloE$" shash="WFbBQ1sliqHUvzPccUTj8JMfMVaiSqG+F9oEx0zxC4kR8MUOnWpJZiMzIFCrymFKAr9kb7vrCNsii60ZGHgrNbVF628EDf6eSYfCrJwSlK5b0FFphUkPFbt2UwyMjmhHLARZp6U5Kl1+w2AmBSleu2kc1DcBRekj3iOjO+N05GM=" originalsrc="https://urldefense.com/v3/__https://aka.ms/o0ukef__;!!JmPEgBY0HMszNaDT!uUJ_jeYf45gcXDGR_PeMjhU7hbd_fKcXJPn0pM9eb-YQihKNYuXMYM9x-hglsbXsCFIwNBWgHXdetHODupsOloE$" shash="F+oAf9PmtZs67KR1BloAoNOwM/azCkZ0dUvnvwdPIrbT6fd6E9rQX5NduQVn48FvKg7tyb9HRX14+6IvE1aFFZtXQoWMAbmCGxzZ4VxDVNP7Uw0Thh5YorNtJ/0rAjxkRLPzY3zXpzHpBe3iCjJE5CJRaP1kP5hL2GF/i3nPvAU=" target="_blank">Outlook
 for iOS</a></div>
<div id="x_x_m_-677654408871201876mail-editor-reference-message-container">
<hr style="display:inline-block; width:917.34375px">
<div id="x_x_m_-677654408871201876divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif"><b>From:</b><span class="x_Apple-converted-space"> </span>Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>><br>
<b>Sent:</b><span class="x_Apple-converted-space"> </span>Wednesday, December 20, 2023 2:48 AM<br>
<b>To:</b><span class="x_Apple-converted-space"> </span>Shatanawi, Sawsan Muhammad <<a href="mailto:sawsan.shatanawi@wsu.edu" target="_blank">sawsan.shatanawi@wsu.edu</a>><br>
<b>Cc:</b><span class="x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><span class="x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_Apple-converted-space"> </span>Re: [petsc-users] Help with Integrating PETSc into Fortran Groundwater Flow Simulation Code
<div> </div>
</font></div>
<div style="margin-top:0px; margin-bottom:0px; border:1px solid rgb(255,202,202); padding:1px; background-color:rgb(255,235,156)">
<span style="font-size:10pt"><b>[EXTERNAL EMAIL]</b></span></div>
<div>
<div dir="ltr">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.
<div>If this is what you want then you can tell the matrix to let you do that.</div>
<div>Otherwise you have a bug.</div>
<div><br>
</div>
<div>Mark</div>
</div>
<br>
<div class="x_x_gmail_quote">
<div dir="ltr" class="x_x_gmail_attr">On Tue, Dec 19, 2023 at 9:50 PM Shatanawi, Sawsan Muhammad via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<blockquote class="x_x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left-width:1px; border-left-style:solid; border-left-color:rgb(204,204,204); padding-left:1ex">
<div>
<div dir="ltr">
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt">
</div>
Hello everyone,
<div><br>
</div>
<div>I hope this email finds you well.</div>
<div><span><br>
</span></div>
<div><span> My Name is Sawsan Shatanawi,</span><span><span style="display:inline; color:rgb(55,65,81)"> 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, </span></span><span>when I tried to assign it as a PETSc matrix I started getting a lot of error messages.</span></div>
<div><br>
</div>
<div>I am kindly asking if someone can help me,<span style="display:inline; color:rgb(55,65,81)"> I would be happy to share my code with him/her.</span></div>
<div><span><br>
</span></div>
<div><span>Please find the attached file contains a list of errors I have gotten</span></div>
<div><span style="color:rgb(55,65,81)"><br>
</span></div>
<div><span style="color:rgb(55,65,81)">Thank you in advance for your time and assistance.</span><br>
</div>
<div><span>
<p style="margin:1.25em 0px; border:0px solid rgb(217,217,227); box-sizing:border-box; color:rgb(55,65,81)">
Best regards,</p>
<p style="margin:1.25em 0px; border:0px solid rgb(217,217,227); box-sizing:border-box; color:rgb(55,65,81)">
 Sawsan</p>
<br>
</span></div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt">
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
<span id="x_cid:66357E60-6F0B-4E28-9883-5421A4F75577"><Matrix_RHS.F90></span><span id="x_cid:FB95EDCC-3170-4E85-BBFB-5804756A9022"><out.txt></span><span id="x_cid:8AF6D377-8CA5-4FFF-81AC-12EFB1837766"><solver.F90></span></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>