[petsc-users] DMLocalToGlobal

Barry Smith bsmith at mcs.anl.gov
Tue Jan 21 22:04:26 CST 2014


On Jan 21, 2014, at 9:52 PM, Dharmendar Reddy <dharmareddy84 at gmail.com> wrote:

> Hello,
>         I am trying to understand the usage rule for DMLocalToGlobalBegin/End.
> 
> I have a sequence of calls like this:
> 
> call DMLocalToGlobalBegin(dm, localLB, INSERT_VALUES, LB, ierr)    ----- (1)
> 
> call DMLocalToGlobalBegin(dm, localUB, INSERT_VALUES, UB, ierr)   ------ (2)
> 
> call DMLocalToGlobalEnd(dm, localLB, INSERT_VALUES, LB, ierr)    ------- (3)
> 
> call DMLocalToGlobalEnd(dm, localUB, INSERT_VALUES, UB, ierr)    --------(4)
> 
> 
> call SNESVISetVariableBounds(snes,LB,UB, ierr)
> 
> 
> SNES fails to run. I get function norm zero right in the first call
> and simulation ends.
> 
> 
> If i change the order of DM calls above to
> 
> 1,3,2,4 then code works as expected
> 
> 
> Does that mean the End call should occur immediately after Begin call ?

  Currently they do need to be called in that order. Note that if you checked the ierr after (2) it would have indicated an error condition. I am surprised that PETSc didn’t print an error message “Scatter ctx already in use”. Note in FORTRAN you can do a lazy check of ierr with 

  call DMLocalToGlobalBegin(dm, localUB, INSERT_VALUES, UB, ierr) ; CHKERRQ(ierr) 

  so it does not make the Fortran code particularly ugly just put the CHKERRQ(ierr) on the same line as the code


  Barry


> 
> 
> Thanks
> Reddy



More information about the petsc-users mailing list