<div dir="ltr">I have petsc 3.3p5 on my Mac. <div><br></div><div><p style="margin:0px;font-size:11px;font-family:Menlo"> PetscInitialize(<span style="color:rgb(194,42,156)">NULL</span>, <span style="color:rgb(194,42,156)">NULL</span>, <span style="color:rgb(194,42,156)">NULL</span>, <span style="color:rgb(194,42,156)">NULL</span>);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo"><span style="font-family:arial;font-size:small">It seems working fine here.</span><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">
<span style="font-family:arial;font-size:small"><br></span></p><p style="margin:0px;font-size:11px;font-family:Menlo"><span style="font-family:arial;font-size:small">Ling</span></p></div></div><div class="gmail_extra"><br>
<br><div class="gmail_quote">On Tue, Jun 25, 2013 at 4:54 PM, Longxiang Chen <span dir="ltr"><<a href="mailto:suifengls@gmail.com" target="_blank">suifengls@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">Dear all,</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">
<br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">I try to use ksp to solve Ax=b.</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">
<br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">ALL programs are in fortran, except petscsolve() in c.<br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">
<br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">Because petscsolve() is a sub-function that I don't have argc and argv.</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">
So I use following statement to set the options.</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)"><br></div><div class="gmail_default"><div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif"> PetscInitialize(NULL, NULL, NULL, help);</font></div>
<div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif"><span style="white-space:pre-wrap"> </span>PetscOptionsSetValue("-ksp_type", "bcgs");</font></div><div class="gmail_default">
<font color="#444444" face="trebuchet ms, sans-serif"><span style="white-space:pre-wrap"> </span>PetscOptionsSetValue("-pc_type", "jacobi");</font></div><div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif"><span style="white-space:pre-wrap"> </span>PetscOptionsSetValue("-ksp_max_it", "100");</font></div>
<div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif"><span style="white-space:pre-wrap"> </span>PetscOptionsInsert(NULL, NULL, NULL);</font></div></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">
<br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">The program works like this:</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">
<br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">main()</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">
Init()</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">LOOP:</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">
call MULTI (calculate Jacob A) </div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">-> call petscsolve( solve Ax=b) </div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">
-> check solution</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">Goto LOOP</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">
<br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">The first iteration works well that I can calculate the solution x from petscsolve().</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)">
But when it enters the second iteration of LOOP, it has Segmentation fault:</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)"><br></div><div class="gmail_default"><div class="gmail_default">
<font color="#444444" face="trebuchet ms, sans-serif">Program received signal SIGSEGV, Segmentation fault.</font></div><div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">0x000000000d8e11f0 in ?? ()</font></div>
<div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">(gdb) bt</font></div><div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">#0 0x000000000d8e11f0 in ?? ()</font></div>
<div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">#1 0x0000000001a32625 in PMPI_Barrier ()</font></div><div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">#2 0x0000000000bdd2b7 in PetscLogBegin_Private () at /home/lchen/ft-petsc/src/sys/logging/plog.c:234</font></div>
<div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">#3 0x0000000000bdd876 in PetscLogBegin () at /home/lchen/ft-petsc/src/sys/logging/plog.c:278</font></div><div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">#4 0x00000000004c1f6c in PetscOptionsCheckInitial_Private ()</font></div>
<div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif"> at /home/lchen/ft-petsc/src/sys/objects/init.c:494</font></div><div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif"><b>#5 0x00000000004cbe6d in PetscInitialize (argc=0x0, args=0x0, file=0x0, </b></font></div>
<div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif"><b> help=0x20a9f00 "Replace with PETSC_solve") at /home/lchen/ft-petsc/src/sys/objects/pinit.c:779</b></font></div><div class="gmail_default">
<font color="#444444" face="trebuchet ms, sans-serif">#6 0x00000000004991e3 in petscsolve_ (N=0x20c7d28, RHS=0x9813500, WKAREA=0x4902c80, NZ=0xc0629e0, </font></div><div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif"> IA=0xb8b9ac0, JA=0x754e520, CO=0x9871ac0, TOL=0x22c0528, ITMAX=0x71ef048, ITER=0x7fffffffd3a8, </font></div>
<div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif"> ERR=0x7fffffffd3b0, IERR=0x7fffffffd3b8, IUNIT=0x1bcb310, RWORK=0x57d2000, LENW=0x49f4cc0, </font></div><div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif"> IWORK=0x3e32860, LENIW=0x49f4cc8) at petscsolve.c:184</font></div>
<div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">#7 0x000000000044ed15 in lineq () at t2cg22.f:1698</font></div><div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">#8 0x000000000046a24c in cycit () at t2f.f:2055</font></div>
<div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">#9 0x00000000004483d3 in tough2 () at t2cg22.f:625</font></div><div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">#10 0x000000000040bfcc in main ()</font></div>
<div class="gmail_default"><br></div><div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">Are there any problems with </font><span style="color:rgb(68,68,68);font-family:'trebuchet ms',sans-serif">PetscInitialize(NULL, NULL, NULL, help)?</span></div>
<div class="gmail_default"><font color="#444444" face="trebuchet ms, sans-serif">Thank you.</font></div></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;color:rgb(68,68,68)"><br></div>
<div><div dir="ltr">Best regards,<div>Longxiang Chen</div><div><br></div></div></div>
</div>
</blockquote></div><br></div>