[petsc-users] Check Array and String Bounds in PETSc

Barry Smith bsmith at mcs.anl.gov
Mon Oct 20 14:31:02 CDT 2014


> On Oct 20, 2014, at 1:44 PM, Danyang Su <danyang.su at gmail.com> wrote:
> 
> On 20/10/2014 11:00 AM, Barry Smith wrote:
>>> On Oct 20, 2014, at 11:56 AM, Danyang Su <danyang.su at gmail.com> wrote:
>>> 
>>> On 19/10/2014 5:06 PM, Barry Smith wrote:
>>>>   Use ISLocalToGlobalMappingGetIndicesF90()
>>> Hi Barry,
>>> 
>>> Would you please give my a brief introduction or example on the parameters for this function? I didn't find it in the PETSc manual page.
>>> The following codes will cause stack overflow. Maybe the idx data type is wrong here. Would you please let me know what data type should be used here?
>>> 
>>> PetscInt, pointer :: idx(:)
>>> call DMGetLocalToGlobalMapping(dmda_flow%da,ltogm,ierr)
>>> call ISLocalToGlobalMappingGetIndicesF90(ltogm,idx,ierr)
>>    Your code above looks ok. You’ll have to be more specific as to what goes wrong. Can you reproduce it in a small example that demonstrates the problem?
>> 
>>   Barry
> It seems tricky. I tried different version of PETSc and different method, as shown below.
> When using PETSc 3.4.4 with the old functions, everything works fine.
> When using PETSc 3.5.2 method 1, everything works except that I cannot use "check array bounds" option, otherwise, the codes stop at "node_idx_lg2pg(ivol) = ...". This is not a big problem but sometimes I need to use this option to debug.
> When using PETSc 3.5.2 method 2, the codes stop at "ISLocalToGlobalMappingGetIndicesF90" with stack overflow.

  What do you mean by “stack overflow”? I have no idea what you mean. Please cut and paste the entire error message, runs in debugger etc

  Barryt

> All the other codes and compiling options are the same.
> 
> #ifdef PETSC_V3_5_X
>        ISLocalToGlobalMapping :: ltogm
> 
>        !Method 1
>        !PetscInt :: ltog(1)
>        !PetscOffset :: idltog
> 
>        !Method 2
>        PetscInt, pointer :: idx(:)
> #else
>        PetscInt, pointer :: idx(:)
> #endif
> 
> #ifdef PETSC_V3_5_X
>        !Method 1
>        !call DMGetLocalToGlobalMapping(dmda_flow%da,ltogm,ierr)
>        !call ISLocalToGlobalMappingGetIndices(ltogm,ltog,idltog,ierr)
> 
>        !Method 2
>        call DMGetLocalToGlobalMapping(dmda_flow%da,ltogm,ierr)
>        call ISLocalToGlobalMappingGetIndicesF90(ltogm,idx,ierr)
> #else
>        call DMDAGetGlobalIndicesF90(dmda_flow%da,PETSC_NULL_INTEGER,  &
>                                     idx,ierr)
> #endif
> 
> #ifdef PETSC_V3_5_X
>            !Method 1
>            !node_idx_lg2pg(ivol) = (ltog(ivol*dof + idltog)+1)/dof
>            !Method 2
> 
>            node_idx_lg2pg(ivol) = (idx(ivol*dof)+1)/dof
> #else
>            node_idx_lg2pg(ivol) = (idx(ivol*dof)+1)/dof
> #endif
> 
> #ifdef PETSC_V3_5_X
>        !Method 1
>        !call ISLocalToGlobalMappingRestoreIndices(ltogm,ltog,idltog,ierr)
> 
>        !Method 2
>        call ISLocalToGlobalMappingRestoreIndicesF90(ltogm,idx,ierr)
> #endif
> 
> Thanks,
> 
> Danyang
>> 
>>> Thanks,
>>> 
>>> Danyang
>>>> 
>>>>> On Oct 19, 2014, at 6:38 PM, Danyang Su <danyang.su at gmail.com> wrote:
>>>>> 
>>>>> Hi All,
>>>>> 
>>>>> How can I avoid "array bounds" error when using PETSc. I have to debug my codes so I compiled the codes with option "Check Array and String Bounds". But  this results into array bounds error when I need to use ltog, as shown below.
>>>>>        call DMGetLocalToGlobalMapping(dmda_flow%da,ltogm,ierr)
>>>>>        call ISLocalToGlobalMappingGetIndices(ltogm,ltog,idltog,ierr)
>>>>> Exactly the aforementioned two lines work fine and the bug is in somewhere else. But the debug process just stops at the codes when ltog is used. How can avoid this?
>>>>> 
>>>>> Thanks,
>>>>> 
>>>>> Danyang



More information about the petsc-users mailing list