check2DP1Bnds2x2 Subroutine

subroutine check2DP1Bnds2x2(grid, coordDim, staggerloc, localPet, petCount, ielbnd0, ieubnd0, iloff0, iuoff0, ielbnd1, ieubnd1, iloff1, iuoff1, ielbnd2, ieubnd2, iloff2, iuoff2, ielbnd3, ieubnd3, iloff3, iuoff3, correct, checkPtr, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Grid) :: grid
integer, intent(in) :: coordDim
type(ESMF_StaggerLoc), intent(in) :: staggerloc
integer, intent(in) :: localPet
integer, intent(in) :: petCount
integer, intent(in) :: ielbnd0(:)
integer, intent(in) :: ieubnd0(:)
integer, intent(in) :: iloff0(:)
integer, intent(in) :: iuoff0(:)
integer, intent(in) :: ielbnd1(:)
integer, intent(in) :: ieubnd1(:)
integer, intent(in) :: iloff1(:)
integer, intent(in) :: iuoff1(:)
integer, intent(in) :: ielbnd2(:)
integer, intent(in) :: ieubnd2(:)
integer, intent(in) :: iloff2(:)
integer, intent(in) :: iuoff2(:)
integer, intent(in) :: ielbnd3(:)
integer, intent(in) :: ieubnd3(:)
integer, intent(in) :: iloff3(:)
integer, intent(in) :: iuoff3(:)
logical, intent(inout) :: correct
logical, intent(in), optional :: checkPtr
integer, intent(inout) :: rc

Source Code

subroutine check2DP1Bnds2x2(grid, coordDim, staggerloc, localPet, petCount, &
                          ielbnd0,ieubnd0,iloff0,iuoff0, &
                          ielbnd1,ieubnd1,iloff1,iuoff1, &
                          ielbnd2,ieubnd2,iloff2,iuoff2, &
                          ielbnd3,ieubnd3,iloff3,iuoff3, &
                          correct, checkPtr,rc)

  type (ESMF_Grid) :: grid
  type (ESMF_StaggerLoc),intent(in) :: staggerloc
  integer,intent(in) :: coordDim, localPet, petCount
  integer,intent(in) :: ielbnd0(:),ieubnd0(:),iloff0(:),iuoff0(:)
  integer,intent(in) :: ielbnd1(:),ieubnd1(:),iloff1(:),iuoff1(:)
  integer,intent(in) :: ielbnd2(:),ieubnd2(:),iloff2(:),iuoff2(:)
  integer,intent(in) :: ielbnd3(:),ieubnd3(:),iloff3(:),iuoff3(:)
  logical,intent(inout) :: correct
  logical,intent(in),optional :: checkPtr
  integer,intent(inout) :: rc  
  integer :: localrc
  integer :: elbnd(3),eubnd(3),ecnt(3)
  integer :: clbnd(3),cubnd(3),ccnt(3)
  integer :: tlbnd(3),tubnd(3),tcnt(3)
  real (ESMF_KIND_R8), pointer :: farrayPtr(:,:,:)
  logical :: locCheckPtr


  if (present(checkPtr)) then
     locCheckPtr=checkPtr
  else     
     locCheckPtr=.true.
  endif


  ! Check if bounds are correct for each DE
  if (petCount .eq. 1) then
      ! Note the order of DE's here is dependant on the ordering
      ! in ESMF_GridCreateNoPeriDim, if that changes then this will
      ! probably have to change also. 

      ! check DE 0
      call ESMF_GridGetCoordBounds(grid, coordDim=coordDim, localDE=0, &
             staggerLoc=staggerloc,                  &
             exclusiveLBound=elbnd, exclusiveUBound=eubnd,       &
             exclusiveCount=ecnt, &
             computationalLBound=clbnd, computationalUBound=cubnd,           &
             computationalCount=ccnt, &
              rc=localrc)

             if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
!   write(*,*) "0:",clbnd,",",cubnd, correct
!   write(*,*) "0: c=",clbnd,",",cubnd,",", ccnt," e=",elbnd,",",eubnd,",", ecnt, correct, rc

     !! set pointer to null
     nullify(farrayPtr)
 
     !! Get Coord Array From Grid
     if (locCheckPtr) then
         call ESMF_GridGetCoord(grid, localDE=0, &
                staggerLoc=staggerloc, coordDim=coordDim, farrayPtr=farrayPtr, totalLBound=tlbnd, totalUBound=tubnd, &
                totalCount=tcnt,  rc=localrc)
         if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
     endif

     !! Check that output is as expected
     if (locCheckPtr) then
        if (.not. associated(farrayPtr)) correct=.false.
        if (lbound(farrayPtr,1) .ne. tlbnd(1))  correct=.false.
        if (lbound(farrayPtr,2) .ne. tlbnd(2))  correct=.false.
        if (lbound(farrayPtr,3) .ne. tlbnd(3))  correct=.false.

        if (ubound(farrayPtr,1) .ne. tubnd(1))  correct=.false.
        if (ubound(farrayPtr,2) .ne. tubnd(2))  correct=.false.
        if (ubound(farrayPtr,3) .ne. tubnd(3))  correct=.false.
     endif

     if (elbnd(1) .ne. ielbnd0(1)-iloff0(1)) correct=.false.
     if (elbnd(2) .ne. ielbnd0(2)-iloff0(2)) correct=.false.
     if (elbnd(3) .ne. ielbnd0(3)-iloff0(3)) correct=.false.

     if (eubnd(1) .ne. ieubnd0(1)+iuoff0(1)) correct=.false.
     if (eubnd(2) .ne. ieubnd0(2)+iuoff0(2)) correct=.false.
     if (eubnd(3) .ne. ieubnd0(3)+iuoff0(3)) correct=.false.

     if (ecnt(1) .ne. ieubnd0(1)-ielbnd0(1)+1+iloff0(1)+iuoff0(1)) correct=.false.
     if (ecnt(2) .ne. ieubnd0(2)-ielbnd0(2)+1+iloff0(2)+iuoff0(2)) correct=.false.
     if (ecnt(3) .ne. ieubnd0(3)-ielbnd0(3)+1+iloff0(3)+iuoff0(3)) correct=.false.

     if (clbnd(1) .ne. ielbnd0(1)-iloff0(1)) correct=.false.
     if (clbnd(2) .ne. ielbnd0(2)-iloff0(2)) correct=.false.
     if (clbnd(3) .ne. ielbnd0(3)-iloff0(3)) correct=.false.

     if (cubnd(1) .ne. ieubnd0(1)+iuoff0(1)) correct=.false.
     if (cubnd(2) .ne. ieubnd0(2)+iuoff0(2)) correct=.false.
     if (cubnd(3) .ne. ieubnd0(3)+iuoff0(3)) correct=.false.

     if (ccnt(1) .ne. ieubnd0(1)-ielbnd0(1)+1+iloff0(1)+iuoff0(1)) correct=.false.
     if (ccnt(2) .ne. ieubnd0(2)-ielbnd0(2)+1+iloff0(2)+iuoff0(2)) correct=.false.
     if (ccnt(3) .ne. ieubnd0(3)-ielbnd0(3)+1+iloff0(3)+iuoff0(3)) correct=.false.

     if (locCheckPtr) then
        if (tlbnd(1) .ne. ielbnd0(1)-iloff0(1)) correct=.false.
        if (tlbnd(2) .ne. ielbnd0(2)-iloff0(2)) correct=.false.
        if (tlbnd(3) .ne. ielbnd0(3)-iloff0(3)) correct=.false.

        if (tubnd(1) .ne. ieubnd0(1)+iuoff0(1)) correct=.false.
        if (tubnd(2) .ne. ieubnd0(2)+iuoff0(2)) correct=.false.
        if (tubnd(3) .ne. ieubnd0(3)+iuoff0(3)) correct=.false.

        if (tcnt(1) .ne. ieubnd0(1)-ielbnd0(1)+1+iloff0(1)+iuoff0(1)) correct=.false.
        if (tcnt(2) .ne. ieubnd0(2)-ielbnd0(2)+1+iloff0(2)+iuoff0(2)) correct=.false.
        if (tcnt(3) .ne. ieubnd0(3)-ielbnd0(3)+1+iloff0(3)+iuoff0(3)) correct=.false.
     endif

      ! check DE 1
      call ESMF_GridGetCoordBounds(grid2D, coordDim=coordDim, localDE=1, &
             staggerLoc=staggerloc,                  &
             exclusiveLBound=elbnd, exclusiveUBound=eubnd,       &
             exclusiveCount=ecnt, &
             computationalLBound=clbnd, computationalUBound=cubnd,           &
             computationalCount=ccnt, &
             rc=localrc)
             if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
!    write(*,*) "1:",clbnd,",",cubnd, rc,correct

     !! set pointer to null
     nullify(farrayPtr)

     !! Get Coord From Grid
     if (locCheckPtr) then
        call ESMF_GridGetCoord(grid, localDE=1, &
                 staggerLoc=staggerloc, coordDim=coordDim, farrayPtr=farrayPtr,  totalLBound=tlbnd, totalUBound=tubnd, &
                 totalCount=tcnt,rc=localrc)
        if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
     endif

     !! Check that output is as expected
     if (locCheckPtr) then
        if (.not. associated(farrayPtr)) correct=.false.
        if (lbound(farrayPtr,1) .ne. tlbnd(1))  correct=.false.
        if (lbound(farrayPtr,2) .ne. tlbnd(2))  correct=.false.
        if (lbound(farrayPtr,3) .ne. tlbnd(3))  correct=.false.

        if (ubound(farrayPtr,1) .ne. tubnd(1))  correct=.false.
        if (ubound(farrayPtr,2) .ne. tubnd(2))  correct=.false.
        if (ubound(farrayPtr,3) .ne. tubnd(3))  correct=.false.
     endif


     if (elbnd(1) .ne. ielbnd1(1)-iloff1(1)) correct=.false.
     if (elbnd(2) .ne. ielbnd1(2)-iloff1(2)) correct=.false.
     if (elbnd(3) .ne. ielbnd1(3)-iloff1(3)) correct=.false.

     if (eubnd(1) .ne. ieubnd1(1)+iuoff1(1)) correct=.false.
     if (eubnd(2) .ne. ieubnd1(2)+iuoff1(2)) correct=.false.
     if (eubnd(3) .ne. ieubnd1(3)+iuoff1(3)) correct=.false.

     if (ecnt(1) .ne. ieubnd1(1)-ielbnd1(1)+1+iloff1(1)+iuoff1(1)) correct=.false.
     if (ecnt(2) .ne. ieubnd1(2)-ielbnd1(2)+1+iloff1(2)+iuoff1(2)) correct=.false.
     if (ecnt(3) .ne. ieubnd1(3)-ielbnd1(3)+1+iloff1(3)+iuoff1(3)) correct=.false.


     if (clbnd(1) .ne. ielbnd1(1)-iloff1(1)) correct=.false.
     if (clbnd(2) .ne. ielbnd1(2)-iloff1(2)) correct=.false.
     if (clbnd(3) .ne. ielbnd1(3)-iloff1(3)) correct=.false.

     if (cubnd(1) .ne. ieubnd1(1)+iuoff1(1)) correct=.false.
     if (cubnd(2) .ne. ieubnd1(2)+iuoff1(2)) correct=.false.
     if (cubnd(3) .ne. ieubnd1(3)+iuoff1(3)) correct=.false.

     if (ccnt(1) .ne. ieubnd1(1)-ielbnd1(1)+1+iloff1(1)+iuoff1(1)) correct=.false.
     if (ccnt(2) .ne. ieubnd1(2)-ielbnd1(2)+1+iloff1(2)+iuoff1(2)) correct=.false.
     if (ccnt(3) .ne. ieubnd1(3)-ielbnd1(3)+1+iloff1(3)+iuoff1(3)) correct=.false.

     if (locCheckPtr) then
        if (tlbnd(1) .ne. ielbnd1(1)-iloff1(1)) correct=.false.
        if (tlbnd(2) .ne. ielbnd1(2)-iloff1(2)) correct=.false.
        if (tlbnd(3) .ne. ielbnd1(3)-iloff1(3)) correct=.false.
        
        if (tubnd(1) .ne. ieubnd1(1)+iuoff1(1)) correct=.false.
        if (tubnd(2) .ne. ieubnd1(2)+iuoff1(2)) correct=.false.
        if (tubnd(3) .ne. ieubnd1(3)+iuoff1(3)) correct=.false.

        if (tcnt(1) .ne. ieubnd1(1)-ielbnd1(1)+1+iloff1(1)+iuoff1(1)) correct=.false.
        if (tcnt(2) .ne. ieubnd1(2)-ielbnd1(2)+1+iloff1(2)+iuoff1(2)) correct=.false.
        if (tcnt(3) .ne. ieubnd1(3)-ielbnd1(3)+1+iloff1(3)+iuoff1(3)) correct=.false.
     endif

      ! check DE 2
      call ESMF_GridGetCoordBounds(grid, coordDim=coordDim, localDE=2, &
             staggerLoc=staggerloc,                  &
             exclusiveLBound=elbnd, exclusiveUBound=eubnd,       &
             exclusiveCount=ecnt, &
             computationalLBound=clbnd, computationalUBound=cubnd,           &
             computationalCount=ccnt, &
              rc=localrc)
             if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
!    write(*,*) "2:",clbnd,",",cubnd, correct

     !! set pointer to null
     nullify(farrayPtr)

     !! Get Coord From Grid
     if (locCheckPtr) then
         call ESMF_GridGetCoord(grid, localDE=2, &
                staggerLoc=staggerloc, coordDim=coordDim, farrayPtr=farrayPtr, totalLBound=tlbnd, totalUBound=tubnd, &
               totalCount=tcnt,  rc=localrc)
         if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
     endif

     !! Check that output is as expected
     if (locCheckPtr) then
        if (.not. associated(farrayPtr)) correct=.false.
        if (lbound(farrayPtr,1) .ne. tlbnd(1))  correct=.false.
        if (lbound(farrayPtr,2) .ne. tlbnd(2))  correct=.false.
        if (lbound(farrayPtr,3) .ne. tlbnd(3))  correct=.false.

        if (ubound(farrayPtr,1) .ne. tubnd(1))  correct=.false.
        if (ubound(farrayPtr,2) .ne. tubnd(2))  correct=.false.
        if (ubound(farrayPtr,3) .ne. tubnd(3))  correct=.false.
     endif


     if (elbnd(1) .ne. ielbnd2(1)-iloff2(1)) correct=.false.
     if (elbnd(2) .ne. ielbnd2(2)-iloff2(2)) correct=.false.
     if (elbnd(3) .ne. ielbnd2(3)-iloff2(3)) correct=.false.

     if (eubnd(1) .ne. ieubnd2(1)+iuoff2(1)) correct=.false.
     if (eubnd(2) .ne. ieubnd2(2)+iuoff2(2)) correct=.false.
     if (eubnd(3) .ne. ieubnd2(3)+iuoff2(3)) correct=.false.

     if (ecnt(1) .ne. ieubnd2(1)-ielbnd2(1)+1+iloff2(1)+iuoff2(1)) correct=.false.
     if (ecnt(2) .ne. ieubnd2(2)-ielbnd2(2)+1+iloff2(2)+iuoff2(2)) correct=.false.
     if (ecnt(3) .ne. ieubnd2(3)-ielbnd2(3)+1+iloff2(3)+iuoff2(3)) correct=.false.

     if (clbnd(1) .ne. ielbnd2(1)-iloff2(1)) correct=.false.
     if (clbnd(2) .ne. ielbnd2(2)-iloff2(2)) correct=.false.
     if (clbnd(3) .ne. ielbnd2(3)-iloff2(3)) correct=.false.

     if (cubnd(1) .ne. ieubnd2(1)+iuoff2(1)) correct=.false.
     if (cubnd(2) .ne. ieubnd2(2)+iuoff2(2)) correct=.false.
     if (cubnd(3) .ne. ieubnd2(3)+iuoff2(3)) correct=.false.

     if (ccnt(1) .ne. ieubnd2(1)-ielbnd2(1)+1+iloff2(1)+iuoff2(1)) correct=.false.
     if (ccnt(2) .ne. ieubnd2(2)-ielbnd2(2)+1+iloff2(2)+iuoff2(2)) correct=.false.
     if (ccnt(3) .ne. ieubnd2(3)-ielbnd2(3)+1+iloff2(3)+iuoff2(3)) correct=.false.

     if (locCheckPtr) then
        if (tlbnd(1) .ne. ielbnd2(1)-iloff2(1)) correct=.false.
        if (tlbnd(2) .ne. ielbnd2(2)-iloff2(2)) correct=.false.
        if (tlbnd(3) .ne. ielbnd2(3)-iloff2(3)) correct=.false.

        if (tubnd(1) .ne. ieubnd2(1)+iuoff2(1)) correct=.false.
        if (tubnd(2) .ne. ieubnd2(2)+iuoff2(2)) correct=.false.
        if (tubnd(3) .ne. ieubnd2(3)+iuoff2(3)) correct=.false.

        if (tcnt(1) .ne. ieubnd2(1)-ielbnd2(1)+1+iloff2(1)+iuoff2(1)) correct=.false.
        if (tcnt(2) .ne. ieubnd2(2)-ielbnd2(2)+1+iloff2(2)+iuoff2(2)) correct=.false.
        if (tcnt(3) .ne. ieubnd2(3)-ielbnd2(3)+1+iloff2(3)+iuoff2(3)) correct=.false.
     endif

      ! check DE 3
      call ESMF_GridGetCoordBounds(grid, coordDim=coordDim, localDE=3, &
             staggerLoc=staggerloc,                  &
             exclusiveLBound=elbnd, exclusiveUBound=eubnd,       &
             exclusiveCount=ecnt, &
             computationalLBound=clbnd, computationalUBound=cubnd,           &
             computationalCount=ccnt, &
             rc=localrc)
             if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE

!    write(*,*) "3:",clbnd,",",cubnd, correct
     !! set pointer to null
     nullify(farrayPtr)

     !! Get Coord From Grid
     if (locCheckPtr) then
        call ESMF_GridGetCoord(grid, localDE=3, &
              staggerLoc=staggerloc, coordDim=coordDim, farrayPtr=farrayPtr,  totalLBound=tlbnd, totalUBound=tubnd, &
             totalCount=tcnt,  rc=localrc)
        if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
     endif

     !! Check that output is as expected
     if (locCheckPtr) then
        if (.not. associated(farrayPtr)) correct=.false.
        if (lbound(farrayPtr,1) .ne. tlbnd(1))  correct=.false.
        if (lbound(farrayPtr,2) .ne. tlbnd(2))  correct=.false.
        if (lbound(farrayPtr,3) .ne. tlbnd(3))  correct=.false.

        if (ubound(farrayPtr,1) .ne. tubnd(1))  correct=.false.
        if (ubound(farrayPtr,2) .ne. tubnd(2))  correct=.false.
        if (ubound(farrayPtr,3) .ne. tubnd(3))  correct=.false.
     endif

     if (elbnd(1) .ne. ielbnd3(1)-iloff3(1)) correct=.false.
     if (elbnd(2) .ne. ielbnd3(2)-iloff3(2)) correct=.false.
     if (elbnd(3) .ne. ielbnd3(3)-iloff3(3)) correct=.false.

     if (eubnd(1) .ne. ieubnd3(1)+iuoff3(1)) correct=.false.
     if (eubnd(2) .ne. ieubnd3(2)+iuoff3(2)) correct=.false.
     if (eubnd(3) .ne. ieubnd3(3)+iuoff3(3)) correct=.false.

     if (ecnt(1) .ne. ieubnd3(1)-ielbnd3(1)+1+iloff3(1)+iuoff3(1)) correct=.false.
     if (ecnt(2) .ne. ieubnd3(2)-ielbnd3(2)+1+iloff3(2)+iuoff3(2)) correct=.false.
     if (ecnt(3) .ne. ieubnd3(3)-ielbnd3(3)+1+iloff3(3)+iuoff3(3)) correct=.false.

     if (clbnd(1) .ne. ielbnd3(1)-iloff3(1)) correct=.false.
     if (clbnd(2) .ne. ielbnd3(2)-iloff3(2)) correct=.false.
     if (clbnd(3) .ne. ielbnd3(3)-iloff3(3)) correct=.false.

     if (cubnd(1) .ne. ieubnd3(1)+iuoff3(1)) correct=.false.
     if (cubnd(2) .ne. ieubnd3(2)+iuoff3(2)) correct=.false.
     if (cubnd(3) .ne. ieubnd3(3)+iuoff3(3)) correct=.false.

     if (ccnt(1) .ne. ieubnd3(1)-ielbnd3(1)+1+iloff3(1)+iuoff3(1)) correct=.false.
     if (ccnt(2) .ne. ieubnd3(2)-ielbnd3(2)+1+iloff3(2)+iuoff3(2)) correct=.false.
     if (ccnt(3) .ne. ieubnd3(3)-ielbnd3(3)+1+iloff3(3)+iuoff3(3)) correct=.false.

     if (locCheckPtr) then
        if (tlbnd(1) .ne. ielbnd3(1)-iloff3(1)) correct=.false.
        if (tlbnd(2) .ne. ielbnd3(2)-iloff3(2)) correct=.false.
        if (tlbnd(3) .ne. ielbnd3(3)-iloff3(3)) correct=.false.

        if (tubnd(1) .ne. ieubnd3(1)+iuoff3(1)) correct=.false.
        if (tubnd(2) .ne. ieubnd3(2)+iuoff3(2)) correct=.false.
        if (tubnd(3) .ne. ieubnd3(3)+iuoff3(3)) correct=.false.

        if (tcnt(1) .ne. ieubnd3(1)-ielbnd3(1)+1+iloff3(1)+iuoff3(1)) correct=.false.
        if (tcnt(2) .ne. ieubnd3(2)-ielbnd3(2)+1+iloff3(2)+iuoff3(2)) correct=.false.
        if (tcnt(3) .ne. ieubnd3(3)-ielbnd3(3)+1+iloff3(3)+iuoff3(3)) correct=.false.
     endif

  else  if (petCount .eq. 4) then
      call ESMF_GridGetCoordBounds(grid, coordDim=coordDim, localDE=0, &
             staggerLoc=staggerloc,                  &
             exclusiveLBound=elbnd, exclusiveUBound=eubnd,       &
             exclusiveCount=ecnt, &
             computationalLBound=clbnd, computationalUBound=cubnd,           &
             computationalCount=ccnt, &
             rc=localrc)
             if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE

!    write(*,*) localPet,":",clbnd,",",cubnd, "rc=",rc, "correct=",correct

      ! set pointer to null
      nullify(farrayPtr)

     ! Get Coord From Grid
     if (locCheckPtr) then
        call ESMF_GridGetCoord(grid, localDE=0, &
              staggerLoc=staggerloc, coordDim=coordDim, farrayPtr=farrayPtr, totalLBound=tlbnd, totalUBound=tubnd, &
             totalCount=tcnt, rc=localrc)
        if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
     endif

     ! Check that output is as expected
     if (locCheckPtr) then
        if (.not. associated(farrayPtr)) correct=.false.
        if (lbound(farrayPtr,1) .ne. tlbnd(1))  correct=.false.
        if (lbound(farrayPtr,2) .ne. tlbnd(2))  correct=.false.
        if (lbound(farrayPtr,3) .ne. tlbnd(3))  correct=.false.

        if (ubound(farrayPtr,1) .ne. tubnd(1))  correct=.false.
        if (ubound(farrayPtr,2) .ne. tubnd(2))  correct=.false.
        if (ubound(farrayPtr,3) .ne. tubnd(3))  correct=.false.
     endif

     if (localPet .eq. 0) then

        if (elbnd(1) .ne. ielbnd0(1)-iloff0(1)) correct=.false.
        if (elbnd(2) .ne. ielbnd0(2)-iloff0(2)) correct=.false.
        if (elbnd(3) .ne. ielbnd0(3)-iloff0(3)) correct=.false.

        if (eubnd(1) .ne. ieubnd0(1)+iuoff0(1)) correct=.false.
        if (eubnd(2) .ne. ieubnd0(2)+iuoff0(2)) correct=.false.
        if (eubnd(3) .ne. ieubnd0(3)+iuoff0(3)) correct=.false.

        if (ecnt(1) .ne. ieubnd0(1)-ielbnd0(1)+1+iloff0(1)+iuoff0(1)) correct=.false.
        if (ecnt(2) .ne. ieubnd0(2)-ielbnd0(2)+1+iloff0(2)+iuoff0(2)) correct=.false.
        if (ecnt(3) .ne. ieubnd0(3)-ielbnd0(3)+1+iloff0(3)+iuoff0(3)) correct=.false.

        if (clbnd(1) .ne. ielbnd0(1)-iloff0(1)) correct=.false.
        if (clbnd(2) .ne. ielbnd0(2)-iloff0(2)) correct=.false.
        if (clbnd(3) .ne. ielbnd0(3)-iloff0(3)) correct=.false.

        if (cubnd(1) .ne. ieubnd0(1)+iuoff0(1)) correct=.false.
        if (cubnd(2) .ne. ieubnd0(2)+iuoff0(2)) correct=.false.
        if (cubnd(3) .ne. ieubnd0(3)+iuoff0(3)) correct=.false.

        if (ccnt(1) .ne. ieubnd0(1)-ielbnd0(1)+1+iloff0(1)+iuoff0(1)) correct=.false.
        if (ccnt(2) .ne. ieubnd0(2)-ielbnd0(2)+1+iloff0(2)+iuoff0(2)) correct=.false.
        if (ccnt(3) .ne. ieubnd0(3)-ielbnd0(3)+1+iloff0(3)+iuoff0(3)) correct=.false.

        if (locCheckPtr) then
           if (elbnd(1) .ne. ielbnd0(1)-iloff0(1)) correct=.false.
           if (elbnd(2) .ne. ielbnd0(2)-iloff0(2)) correct=.false.
           if (elbnd(3) .ne. ielbnd0(3)-iloff0(3)) correct=.false.

           if (eubnd(1) .ne. ieubnd0(1)+iuoff0(1)) correct=.false.
           if (eubnd(2) .ne. ieubnd0(2)+iuoff0(2)) correct=.false.
           if (eubnd(3) .ne. ieubnd0(3)+iuoff0(3)) correct=.false.

           if (ecnt(1) .ne. ieubnd0(1)-ielbnd0(1)+1+iloff0(1)+iuoff0(1)) correct=.false.
           if (ecnt(2) .ne. ieubnd0(2)-ielbnd0(2)+1+iloff0(2)+iuoff0(2)) correct=.false.
           if (ecnt(3) .ne. ieubnd0(3)-ielbnd0(3)+1+iloff0(3)+iuoff0(3)) correct=.false.
        endif

     else if (localPet .eq. 1) then
        if (elbnd(1) .ne. ielbnd1(1)-iloff1(1)) correct=.false.
        if (elbnd(2) .ne. ielbnd1(2)-iloff1(2)) correct=.false.
        if (elbnd(3) .ne. ielbnd1(3)-iloff1(3)) correct=.false.

        if (eubnd(1) .ne. ieubnd1(1)+iuoff1(1)) correct=.false.
        if (eubnd(2) .ne. ieubnd1(2)+iuoff1(2)) correct=.false.
        if (eubnd(3) .ne. ieubnd1(3)+iuoff1(3)) correct=.false.

        if (ecnt(1) .ne. ieubnd1(1)-ielbnd1(1)+1+iloff1(1)+iuoff1(1)) correct=.false.
        if (ecnt(2) .ne. ieubnd1(2)-ielbnd1(2)+1+iloff1(2)+iuoff1(2)) correct=.false.
        if (ecnt(3) .ne. ieubnd1(3)-ielbnd1(3)+1+iloff1(3)+iuoff1(3)) correct=.false.

        if (clbnd(1) .ne. ielbnd1(1)-iloff1(1)) correct=.false.
        if (clbnd(2) .ne. ielbnd1(2)-iloff1(2)) correct=.false.
        if (clbnd(3) .ne. ielbnd1(3)-iloff1(3)) correct=.false.

        if (cubnd(1) .ne. ieubnd1(1)+iuoff1(1)) correct=.false.
        if (cubnd(2) .ne. ieubnd1(2)+iuoff1(2)) correct=.false.
        if (cubnd(3) .ne. ieubnd1(3)+iuoff1(3)) correct=.false.

        if (ccnt(1) .ne. ieubnd1(1)-ielbnd1(1)+1+iloff1(1)+iuoff1(1)) correct=.false.
        if (ccnt(2) .ne. ieubnd1(2)-ielbnd1(2)+1+iloff1(2)+iuoff1(2)) correct=.false.
        if (ccnt(3) .ne. ieubnd1(3)-ielbnd1(3)+1+iloff1(3)+iuoff1(3)) correct=.false.

        if (locCheckPtr) then
           if (tlbnd(1) .ne. ielbnd1(1)-iloff1(1)) correct=.false.
           if (tlbnd(2) .ne. ielbnd1(2)-iloff1(2)) correct=.false.
           if (tlbnd(3) .ne. ielbnd1(3)-iloff1(3)) correct=.false.

           if (tubnd(1) .ne. ieubnd1(1)+iuoff1(1)) correct=.false.
           if (tubnd(2) .ne. ieubnd1(2)+iuoff1(2)) correct=.false.
           if (tubnd(3) .ne. ieubnd1(3)+iuoff1(3)) correct=.false.

           if (tcnt(1) .ne. ieubnd1(1)-ielbnd1(1)+1+iloff1(1)+iuoff1(1)) correct=.false.
           if (tcnt(2) .ne. ieubnd1(2)-ielbnd1(2)+1+iloff1(2)+iuoff1(2)) correct=.false.
           if (tcnt(3) .ne. ieubnd1(3)-ielbnd1(3)+1+iloff1(3)+iuoff1(3)) correct=.false.
        endif

     else if (localPet .eq. 2) then
        if (elbnd(1) .ne. ielbnd2(1)-iloff2(1)) correct=.false.
        if (elbnd(2) .ne. ielbnd2(2)-iloff2(2)) correct=.false.
        if (elbnd(3) .ne. ielbnd2(3)-iloff2(3)) correct=.false.

        if (eubnd(1) .ne. ieubnd2(1)+iuoff2(1)) correct=.false.
        if (eubnd(2) .ne. ieubnd2(2)+iuoff2(2)) correct=.false.
        if (eubnd(3) .ne. ieubnd2(3)+iuoff2(3)) correct=.false.

        if (ecnt(1) .ne. ieubnd2(1)-ielbnd2(1)+1+iloff2(1)+iuoff2(1)) correct=.false.
        if (ecnt(2) .ne. ieubnd2(2)-ielbnd2(2)+1+iloff2(2)+iuoff2(2)) correct=.false.
        if (ecnt(3) .ne. ieubnd2(3)-ielbnd2(3)+1+iloff2(3)+iuoff2(3)) correct=.false.

        if (clbnd(1) .ne. ielbnd2(1)-iloff2(1)) correct=.false.
        if (clbnd(2) .ne. ielbnd2(2)-iloff2(2)) correct=.false.
        if (clbnd(3) .ne. ielbnd2(3)-iloff2(3)) correct=.false.

        if (cubnd(1) .ne. ieubnd2(1)+iuoff2(1)) correct=.false.
        if (cubnd(2) .ne. ieubnd2(2)+iuoff2(2)) correct=.false.
        if (cubnd(3) .ne. ieubnd2(3)+iuoff2(3)) correct=.false.

        if (ccnt(1) .ne. ieubnd2(1)-ielbnd2(1)+1+iloff2(1)+iuoff2(1)) correct=.false.
        if (ccnt(2) .ne. ieubnd2(2)-ielbnd2(2)+1+iloff2(2)+iuoff2(2)) correct=.false.
        if (ccnt(3) .ne. ieubnd2(3)-ielbnd2(3)+1+iloff2(3)+iuoff2(3)) correct=.false.

        if (locCheckPtr) then
           if (tlbnd(1) .ne. ielbnd2(1)-iloff2(1)) correct=.false.
           if (tlbnd(2) .ne. ielbnd2(2)-iloff2(2)) correct=.false.
           if (tlbnd(3) .ne. ielbnd2(3)-iloff2(3)) correct=.false.

           if (tubnd(1) .ne. ieubnd2(1)+iuoff2(1)) correct=.false.
           if (tubnd(2) .ne. ieubnd2(2)+iuoff2(2)) correct=.false.
           if (tubnd(3) .ne. ieubnd2(3)+iuoff2(3)) correct=.false.

           if (tcnt(1) .ne. ieubnd2(1)-ielbnd2(1)+1+iloff2(1)+iuoff2(1)) correct=.false.
           if (tcnt(2) .ne. ieubnd2(2)-ielbnd2(2)+1+iloff2(2)+iuoff2(2)) correct=.false.
           if (tcnt(3) .ne. ieubnd2(3)-ielbnd2(3)+1+iloff2(3)+iuoff2(3)) correct=.false.
        endif
     else if (localPet .eq. 3) then

        if (elbnd(1) .ne. ielbnd3(1)-iloff3(1)) correct=.false.
        if (elbnd(2) .ne. ielbnd3(2)-iloff3(2)) correct=.false.
        if (elbnd(3) .ne. ielbnd3(3)-iloff3(3)) correct=.false.

        if (eubnd(1) .ne. ieubnd3(1)+iuoff3(1)) correct=.false.
        if (eubnd(2) .ne. ieubnd3(2)+iuoff3(2)) correct=.false.
        if (eubnd(3) .ne. ieubnd3(3)+iuoff3(3)) correct=.false.

        if (ecnt(1) .ne. ieubnd3(1)-ielbnd3(1)+1+iloff3(1)+iuoff3(1)) correct=.false.
        if (ecnt(2) .ne. ieubnd3(2)-ielbnd3(2)+1+iloff3(2)+iuoff3(2)) correct=.false.
        if (ecnt(3) .ne. ieubnd3(3)-ielbnd3(3)+1+iloff3(3)+iuoff3(3)) correct=.false.

        if (clbnd(1) .ne. ielbnd3(1)-iloff3(1)) correct=.false.
        if (clbnd(2) .ne. ielbnd3(2)-iloff3(2)) correct=.false.
        if (clbnd(3) .ne. ielbnd3(3)-iloff3(3)) correct=.false.

        if (cubnd(1) .ne. ieubnd3(1)+iuoff3(1)) correct=.false.
        if (cubnd(2) .ne. ieubnd3(2)+iuoff3(2)) correct=.false.
        if (cubnd(3) .ne. ieubnd3(3)+iuoff3(3)) correct=.false.

        if (ccnt(1) .ne. ieubnd3(1)-ielbnd3(1)+1+iloff3(1)+iuoff3(1)) correct=.false.
        if (ccnt(2) .ne. ieubnd3(2)-ielbnd3(2)+1+iloff3(2)+iuoff3(2)) correct=.false.
        if (ccnt(3) .ne. ieubnd3(3)-ielbnd3(3)+1+iloff3(3)+iuoff3(3)) correct=.false.

        if (locCheckPtr) then
           if (tlbnd(1) .ne. ielbnd3(1)-iloff3(1)) correct=.false.
           if (tlbnd(2) .ne. ielbnd3(2)-iloff3(2)) correct=.false.
           if (tlbnd(3) .ne. ielbnd3(3)-iloff3(3)) correct=.false.

           if (tubnd(1) .ne. ieubnd3(1)+iuoff3(1)) correct=.false.
           if (tubnd(2) .ne. ieubnd3(2)+iuoff3(2)) correct=.false.
           if (tubnd(3) .ne. ieubnd3(3)+iuoff3(3)) correct=.false.

           if (tcnt(1) .ne. ieubnd3(1)-ielbnd3(1)+1+iloff3(1)+iuoff3(1)) correct=.false.
           if (tcnt(2) .ne. ieubnd3(2)-ielbnd3(2)+1+iloff3(2)+iuoff3(2)) correct=.false.
           if (tcnt(3) .ne. ieubnd3(3)-ielbnd3(3)+1+iloff3(3)+iuoff3(3)) correct=.false.
        endif
     endif
  endif
end subroutine check2DP1Bnds2x2