[petsc-users] using PETSC_NULL_INTEGER in preallocation routines

Smith, Barry F. bsmith at mcs.anl.gov
Mon May 14 12:56:21 CDT 2018



> On May 14, 2018, at 12:04 PM, Sanjay Govindjee <s_g at berkeley.edu> wrote:
> 
> Yes the error is shape mis-match since PETSC_NULL_INTEGER has been changed to be an array (whereas it used to just be an integer), and the subroutine is expecting an integer not an array.
> 
> If 0 is what will always be expected, then I agree, just pass 0. But if there is a potential for this to change
> in the future, then it seems better to hide this under a named entity.

   This argument is actually ignored if you provide the d/o_nnz argument so 0 will always work.

  Barry

> 
> -sanjay
> 
> On 5/14/18 5:52 PM, Smith, Barry F. wrote:
>> 
>>> On May 14, 2018, at 10:45 AM, Sanjay Govindjee <s_g at berkeley.edu> wrote:
>>> 
>>> Barry,
>>>   Is it then incorrect (and potentially dangerous) to use PETSC_NULL_INTEGER(1) for these arguments, even if that
>>> currently works?
>>    I thought you got warnings or errors because you are passing an array instead of a value?
>> 
>>    Anyways since Fortran is pass by reference passing either a PetscInt   II or  PetscInt II(1) does the same things but modern Fortran compilers require you to pass a scalar when expected (II) and an array when expected (II(1)) otherwise the compiler warns or errors. Better to pass what is expected, in this case a 0.
>> 
>>     Barry
>> 
>>> -sanjay
>>> 
>>> On 5/14/18 5:40 PM, Smith, Barry F. wrote:
>>>> Chris,
>>>> 
>>>>    These arguments should never have been PETSC_NULL_INTEGER since they are integers (and not pointers or arrays), you should pass 0 for them.
>>>> 
>>>>   Barry
>>>> 
>>>> 
>>>>> On May 14, 2018, at 4:45 AM, Klaij, Christiaan <C.Klaij at marin.nl> wrote:
>>>>> 
>>>>> With petsc-3.7.5, I had F90 code like this:
>>>>> 
>>>>>  CALL MatSeqAIJSetPreallocation(aa_symmetric,PETSC_NULL_INTEGER,d_nnz,ierr); CHKERRQ(ierr)
>>>>>  CALL MatMPIAIJSetPreallocation(aa_symmetric,PETSC_NULL_INTEGER,d_nnz,PETSC_NULL_INTEGER,o_nnz,ierr); CHKERRQ(ierr)
>>>>> 
>>>>> which worked fine. Now, with petsc-3.8.4, the same code gives this compilation error:
>>>>> 
>>>>>  error #6634: The shape matching rules of actual arguments and dummy arguments have been violated.   [PETSC_NULL_INTEGER]
>>>>>  CALL MatSeqAIJSetPreallocation(aa_symmetric,PETSC_NULL_INTEGER,d_nnz,ierr); if (ierr .ne. 0) then ; call PetscErrorF(ierr); return; endif
>>>>> ----------------------------------------------^
>>>>>  error #6634: The shape matching rules of actual arguments and dummy arguments have been violated.   [PETSC_NULL_INTEGER]
>>>>>  CALL MatMPIAIJSetPreallocation(aa_symmetric,PETSC_NULL_INTEGER,d_nnz,PETSC_NULL_INTEGER,o_nnz,ierr); if (ierr .ne. 0) then ; call PetscErrorF(ierr); return; endif
>>>>> ----------------------------------------------^
>>>>> 
>>>>> What's the intended usage now, simply 0 instead of PETSC_NULL_INTEGER?
>>>>> 
>>>>> Chris
>>>>> 
>>>>> 
>>>>> dr. ir. Christiaan Klaij  | Senior Researcher | Research & Development
>>>>> MARIN | T +31 317 49 33 44 | mailto:C.Klaij at marin.nl | http://www.marin.nl
>>>>> 
>>>>> MARIN news: http://www.marin.nl/web/News/News-items/120-papers-presented-at-NAV2018.htm
>>>>> 
> 



More information about the petsc-users mailing list