[petsc-users] Checking for NULL Objects in Fortran

Jed Brown jed at jedbrown.org
Mon Sep 10 16:24:08 CDT 2018


"Fabian.Jakub" <Fabian.Jakub at physik.uni-muenchen.de> writes:

> Greetings my dear PETSc list.
>
> In my Fortran Code, I usually checked against PETSC_NULL_DM or
> PETSC_NULL_IS after calling methods such as DMPlexDistribute or
> DMGetStratumIS.
>
> Recently this fails me.
>
> I saw the DMPlexDistribute example in
> dm/label/examples/tutorials/ex1f90.F90
>
> where the value of dm_distributed%v is compared against -1

This code

  if (dmDist%v /= -1) then
    call DMDestroy(dm,ierr);CHKERRA(ierr)
    dm%v = dmDist%v
  end if

should have used PETSC_NULL_DM instead of -1, but now it can just

  call DMDestroy(dm,ierr);CHKERRA(ierr)

without needing to check.

> Now, after the recent change of PETSC_NULL_DM (tDM(1) -> tDM(0) in
> 3d1df95b1) I am not 100% percent sure how to deal with it.
>
> Could you please clarify if testing against ``-1`` is the intended way
> to do it or may this change again soonish?
>
> Many Thanks,
>
> Fabian
>
>
> Here some code snippets to clarify what lead me to put up this question...
>
> This used to validate:
>
> call DMGetStratumIS(dm, 'DomainBoundary', SIDEFACE, bc_idx, ierr)
> if (bc_ids.eq.PETSC_NULL_IS) then ! dont have domain boundary points
> ...
> endif
>
> or
>
> call DMPlexDistribute(dm, i0, PETSC_NULL_SF, dmdist, ierr)
> if (dmdist.eq.PETSC_NULL_DM) then ! DM was not distributed
> endif
>
>
> Now I could do something like:
>
> if(bc_ids%v.eq.-1)
>
> of (dmdist%v.eq.-1)
>
> ...


More information about the petsc-users mailing list