<div dir="ltr"><div>Change below fixed the problem. I'll turn off additional ops later.</div><div>Hong</div><div><br></div><div><br></div><div>diff --git a/src/mat/impls/aij/seq/aij.c b/src/mat/impls/aij/seq/aij.c</div><div>index 1e0b0b8..5cee782 100644</div><div>--- a/src/mat/impls/aij/seq/aij.c</div><div>+++ b/src/mat/impls/aij/seq/aij.c</div><div>@@ -4169,6 +4169,11 @@ PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm comm,PetscInt m,PetscInt n,Pe</div><div> }</div><div> #endif</div><div><br></div><div>+ if (!a) {</div><div>+ (*mat)->ops->view = 0;</div><div>+ }</div><div>+</div><div> ierr = MatAssemblyBegin(*mat,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</div><div><br></div><div>Hong</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 9, 2017 at 4:53 PM, Hong <span dir="ltr"><<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</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">I'll check it tomorrow and fix it.<span class="HOEnZb"><font color="#888888"><div>Hong</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 9, 2017 at 4:27 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
When called with a NULL set of numerical values MatCreateSeqAIJWithArrays() should turn off the function pointers for things that don't make sense for matrices without numerical values, for example MatMult() and MatView(), in fact most function pointers don't make sense and should be turned off.<br>
This could be done with a<br>
if (!a) {<br>
...<br>
}<br>
after the call to MatSetType().<br>
<span class="m_-6069343281953066634HOEnZb"><font color="#888888"><br>
Barry<br>
</font></span><div class="m_-6069343281953066634HOEnZb"><div class="m_-6069343281953066634h5"><br>
> On Feb 9, 2017, at 4:08 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br>
><br>
> On Thu, Feb 9, 2017 at 4:00 PM, Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>> wrote:<br>
> Oh my, this example also segfaults (at least on my Mac) when running:<br>
> mpirun -np 1 ./ex1 -pc_type gamg -mat_view<br>
><br>
> Hong, in<br>
><br>
> MatTransposeMatMultSymbolic_S<wbr>eqAIJ_SeqAIJ() on line 1015<br>
><br>
> you create a matrix without values, not surprising since this is the symbolic phase. However,<br>
> it calls MatAssemblyEnd(), which calls ViewFromOptions(), which gets an SEGV because<br>
> it does not think to check if a->a is NULL.<br>
><br>
> a) Should we make View robust to missing matrix values?<br>
><br>
> b) I don't think this internal matrix should really be viewed like this, so maybe change its prefix?<br>
><br>
> Thanks,<br>
><br>
> Matt<br>
><br>
> [0]PETSC ERROR: [0] MatView_SeqAIJ_ASCII line 560 /Volumes/Data/Repositories/pet<wbr>sc/src/mat/impls/aij/seq/aij.c<br>
> [0]PETSC ERROR: [0] MatView_SeqAIJ line 915 /Volumes/Data/Repositories/pet<wbr>sc/src/mat/impls/aij/seq/aij.c<br>
> [0]PETSC ERROR: [0] MatView line 920 /Volumes/Data/Repositories/pet<wbr>sc/src/mat/interface/matrix.c<br>
> [0]PETSC ERROR: [0] PetscObjectView line 92 /Volumes/Data/Repositories/pet<wbr>sc/src/sys/objects/destroy.c<br>
> [0]PETSC ERROR: [0] PetscObjectViewFromOptions line 2702 /Volumes/Data/Repositories/pet<wbr>sc/src/sys/objects/options.c<br>
> [0]PETSC ERROR: [0] MatAssemblyEnd line 5151 /Volumes/Data/Repositories/pet<wbr>sc/src/mat/interface/matrix.c<br>
> [0]PETSC ERROR: [0] MatCreateSeqAIJWithArrays line 4137 /Volumes/Data/Repositories/pet<wbr>sc/src/mat/impls/aij/seq/aij.c<br>
> [0]PETSC ERROR: [0] MatTransposeMatMultSymbolic_Se<wbr>qAIJ_SeqAIJ line 1012 /Volumes/Data/Repositories/pet<wbr>sc/src/mat/impls/aij/seq/matma<wbr>tmult.c<br>
> [0]PETSC ERROR: [0] MatTransposeMatMult_SeqAIJ_Seq<wbr>AIJ line 994 /Volumes/Data/Repositories/pet<wbr>sc/src/mat/impls/aij/seq/matma<wbr>tmult.c<br>
> [0]PETSC ERROR: [0] MatTransposeMatMult line 9607 /Volumes/Data/Repositories/pet<wbr>sc/src/mat/interface/matrix.c<br>
> [0]PETSC ERROR: [0] PCGAMGCoarsen_AGG line 914 /Volumes/Data/Repositories/pet<wbr>sc/src/ksp/pc/impls/gamg/agg.c<br>
> [0]PETSC ERROR: [0] PCSetUp_GAMG line 425 /Volumes/Data/Repositories/pet<wbr>sc/src/ksp/pc/impls/gamg/gamg.<wbr>c<br>
> [0]PETSC ERROR: [0] PCSetUp line 886 /Volumes/Data/Repositories/pet<wbr>sc/src/ksp/pc/interface/precon<wbr>.c<br>
> [0]PETSC ERROR: [0] KSPSetUp line 291 /Volumes/Data/Repositories/pet<wbr>sc/src/ksp/ksp/interface/itfun<wbr>c.c<br>
><br>
> [0]PETSC ERROR: Petsc Development GIT revision: v3.7.5-3046-gde967d2 GIT Date: 2017-02-09 18:59:37 +0000<br>
> [0]PETSC ERROR: Configure options --LDFLAGS=-L/opt/intel/lib --download-hypre --download-metis --download-mumps --download-parmetis --download-pastix --download-ptscotch --with-blacs-include=/opt/inte<wbr>l/mkl/include --with-blacs-lib=/opt/intel/mk<wbr>l/lib/libmkl_blacs_mpich_lp64.<wbr>so --with-blaslapack-dir=/opt/int<wbr>el/mkl --with-chtml=0 --with-mkl_pardiso-include=/op<wbr>t/intel/mkl/include --with-mkl_pardiso=1 --with-scalapack-include=/opt/<wbr>intel/mkl/include --with-scalapack-lib="[/opt/in<wbr>tel/mkl/lib/libmkl_scalapack_<wbr>lp64.so,/opt/intel/mkl/lib/<wbr>libmkl_blacs_mpich_lp64.so]" --with-shared-libraries=1 --with-x=1 PETSC_ARCH=arch-darwin-c-debug<br>
><br>
>> On Feb 9, 2017, at 10:52 PM, Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>> wrote:<br>
>><br>
>> There, attached.<br>
>><br>
>> Thanks.<br>
>><br>
>> PS: here is the patch also, just in case<br>
>> diff --git a/src/ksp/ksp/examples/tutoria<wbr>ls/ex1.c b/src/ksp/ksp/examples/tutoria<wbr>ls/ex1.c<br>
>> index 6382c09..d9dc69a 100644<br>
>> --- a/src/ksp/ksp/examples/tutoria<wbr>ls/ex1.c<br>
>> +++ b/src/ksp/ksp/examples/tutoria<wbr>ls/ex1.c<br>
>> @@ -123,6 +123,11 @@ int main(int argc,char **args)<br>
>> routines.<br>
>> */<br>
>> ierr = KSPSetFromOptions(ksp);CHKERRQ<wbr>(ierr);<br>
>> + ierr = KSPSetUp(ksp);CHKERRQ(ierr);<br>
>> + char right_options[] = "-ksp_norm_type unpreconditioned -ksp_pc_side right";<br>
>> + PetscOptionsInsertString(NULL,<wbr>right_options);<br>
>> + ierr = KSPSetFromOptions(ksp);CHKERRQ<wbr>(ierr);<br>
>> + ierr = KSPSetUp(ksp);CHKERRQ(ierr);<br>
>><br>
>> if (nonzeroguess) {<br>
>> PetscScalar p = .5;<br>
>><br>
>> <ex1.c><br>
>><br>
>>> On Feb 9, 2017, at 2:56 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br>
>>><br>
>>> On Thu, Feb 9, 2017 at 7:48 AM, Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>> wrote:<br>
>>>> On Feb 9, 2017, at 2:31 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br>
>>>><br>
>>>> On Thu, Feb 9, 2017 at 7:29 AM, Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>> wrote:<br>
>>>><br>
>>>>> On Feb 9, 2017, at 2:17 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br>
>>>>><br>
>>>>> On Thu, Feb 9, 2017 at 7:06 AM, Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>> wrote:<br>
>>>>><br>
>>>>>> On Feb 9, 2017, at 1:37 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br>
>>>>>><br>
>>>>>> On Thu, Feb 9, 2017 at 4:56 AM, Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>> wrote:<br>
>>>>>> Hello,<br>
>>>>>> I _might_ be doing something wrong when calling KSPSetFromOptions/KSPSetUp, but still, am I supposed to get this kind of error?<br>
>>>>>> [0]PETSC ERROR: No support for this operation for this object type<br>
>>>>>> [0]PETSC ERROR: KSP gmres does not support PRECONDITIONED with RIGHT<br>
>>>>>><br>
>>>>>> If not, I’ll try to send a MWE (it basically depends on where I set the option -ksp_pc_side right).<br>
>>>>>><br>
>>>>>> I believe its telling you that it cannot display the preconditioned residual with right preconditioning, which is true.<br>
>>>>>> Are you requesting both?<br>
>>>>><br>
>>>>> No, I’m just using -ksp_view and -ksp_pc_side right. In the “standard” case, it obviously work.<br>
>>>>> However, the error is triggered if I set -ksp_pc_side right after a first call to KSPSetOperators()/KSPSetUp() without destroying the KSP.<br>
>>>>> Should I destroy my KSP before changing from left- (default) to right-preconditioning if KSPSetOperators()/KSPSetUp has already been called?<br>
>>>>><br>
>>>>> Its likely you have to use<br>
>>>>><br>
>>>>> <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSetNormType.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/<wbr>petsc-current/docs/manualpages<wbr>/KSP/KSPSetNormType.html</a><br>
>>>>><br>
>>>>> or<br>
>>>>><br>
>>>>> -ksp_norm_type unpreconditioned<br>
>>>><br>
>>>> If I use this after my first call to KSPSetUp, I now end up with:<br>
>>>> [0]PETSC ERROR: KSP gmres does not support UNPRECONDITIONED with LEFT<br>
>>>><br>
>>>> Yes, you would need to use it at the same time that you change the preconditioning side.<br>
>>><br>
>>> Yes, I’m using PetscOptionsInsert, and whether I let PETSc parse "-ksp_pc_side right -ksp_norm_type unpreconditioned” or "-ksp_norm_type unpreconditioned -ksp_pc_side right” I end up with the same error afterwards.<br>
>>><br>
>>> Can you make an example do it (SNES ex5)? Or can you send a small example that does it?<br>
>>><br>
>>> Thanks,<br>
>>><br>
>>> Matt<br>
>>><br>
>>> Thanks.<br>
>>><br>
>>>> Thanks,<br>
>>>><br>
>>>> Matt<br>
>>>>> since we would not have a chance to change it since its been set already.<br>
>>>>><br>
>>>>> Thanks,<br>
>>>>><br>
>>>>> Matt<br>
>>>>><br>
>>>>> Thanks.<br>
>>>>><br>
>>>>>> Thanks,<br>
>>>>>><br>
>>>>>> Matt<br>
>>>>>><br>
>>>>>> Thanks,<br>
>>>>>> Pierre<br>
>>>>>><br>
>>>>>><br>
>>>>>><br>
>>>>>> --<br>
>>>>>> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
>>>>>> -- Norbert Wiener<br>
>>>>><br>
>>>>><br>
>>>>><br>
>>>>><br>
>>>>> --<br>
>>>>> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
>>>>> -- Norbert Wiener<br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>> --<br>
>>>> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
>>>> -- Norbert Wiener<br>
>>><br>
>>><br>
>>><br>
>>><br>
>>> --<br>
>>> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
>>> -- Norbert Wiener<br>
>><br>
><br>
><br>
><br>
><br>
> --<br>
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
> -- Norbert Wiener<br>
<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>