anchor.diff:              do i = 1,mx
                  do jbc = 1,mbc
                     qthis(i,1-jbc,mq) = qneighbor(i,jbc,mq)
  -                  qneighbor(i,1-jbc,mq) = qthis(i,jbc,mq)
  +                   qneighbor(i,1-jbc,mq) = qthis(i,jbc,mq)
                  enddo
               enddo
            elseif (iface .eq. 3) then
  
positive.code:             ic_add = igrid*mx/p4est_refineFactor
              do i = 1,mx/p4est_refineFactor
                 do jbc = 1,mbc
                    sumfine = 0
                    do ii = 1,refratio
                       do jj = 1,refratio
                          ifine = (i-1)*refratio + ii
                          jfine = (jbc-1)*refratio + jj
                          if (iface_coarse .eq. 2) then
                             qf = qfine(ifine,jfine,mq)
                             areaf = areafine(ifine,jfine)
                          else
                             qf = qfine(ifine,my+1-jfine,mq)
                             areaf = areafine(ifine,my+1-jfine)
                          endif
                          sumfine = sumfine + areaf*qf
                       enddo
                    enddo
                    if (iface_coarse .eq. 2) then
                       areac = areacoarse(i+ic_add,1-jbc)
                       qcoarse(i+ic_add,1-jbc,mq) = sumfine/areac
                    else
                       areac = areacoarse(i+ic_add,my+jbc)
                       qcoarse(i+ic_add,my+jbc,mq) = sumfine/areac
                    endif
                 enddo
              enddo
  
negative.code:      &      icorner,iblock)
        implicit none
  
        integer mx, my, mbc, meqn, icorner, iblock, refratio
        double precision areacoarse(-mbc:mx+mbc+1,-mbc:my+mbc+1)
        double precision areafine(-mbc:mx+mbc+1,-mbc:my+mbc+1)
  
        double precision qcoarse(1-mbc:mx+mbc,1-mbc:my+mbc,meqn)
        double precision qfine(1-mbc:mx+mbc,1-mbc:my+mbc,meqn)
  
        integer mq, ibc, jbc, ii, jj, ifine, jfine
        double precision sum,qf,kf,kc
  
  
        do mq = 1,meqn
           if (icorner .eq. 0) then
              do ibc = 1,mbc
                 do jbc = 1,mbc
                    sum = 0
                    do ii = 1,refratio
                       do jj = 1,refratio
                          ifine = (ibc-1)*refratio + ii
                          jfine = (jbc-1)*refratio + jj
                          qf = qfine(ifine,jfine,mq)
                          kf = areafine(ifine,jfine)
                          sum = sum + kf*qf
                       enddo
                    enddo
                    kc = areacoarse(1-ibc,1-ibc)
                    qcoarse(1-ibc,1-jbc,mq) = sum/kc
                 enddo
              enddo
           elseif (icorner .eq. 1) then
              do ibc = 1,mbc
                 do jbc = 1,mbc
                    sum = 0
                    do ii = 1,refratio
                       do jj = 1,refratio
                          ifine = (ibc-1)*refratio + ii
                          jfine = (jbc-1)*refratio + jj
                          qf = qfine(mx+1-ifine,jfine,mq)
                          kf = areafine(mx+1-ifine,jfine)
                          sum = sum + kf*qf
                       enddo
                    enddo
                    kc = areacoarse(mx+ibc,1-jbc)
                    qcoarse(mx+ibc,1-jbc,mq) = sum/kc
                 enddo
              enddo
           elseif (icorner .eq. 2) then
              do ibc = 1,mbc
                 do jbc = 1,mbc
                    sum = 0
                    do ii = 1,refratio
                       do jj = 1,refratio
                          ifine = (ibc-1)*refratio + ii
                          jfine = (jbc-1)*refratio + jj
                          qf = qfine(ifine,my+1-jfine,mq)
                          kf = areafine(ifine,my+1-jfine)
                          sum = sum + kf*qf
                       enddo
                    enddo
                    kc = areacoarse(1-ibc,my+jbc)
                    qcoarse(1-ibc,my+jbc,mq) = sum/kc
                 enddo
              enddo
           elseif (icorner .eq. 3) then
              do ibc = 1,mbc
                 do jbc = 1,mbc
                    sum = 0
                    do ii = 1,refratio
                       do jj = 1,refratio
                          ifine = (ibc-1)*refratio + ii
                          jfine = (jbc-1)*refratio + jj
                          qf = qfine(mx+1-ifine,my+1-jfine,mq)
                          kf = areafine(mx+1-ifine,my+1-jfine)
                          sum = sum + kf*qf
                       enddo
                    enddo
                    kc = areacoarse(mx+ibc,my+jbc)
                    qcoarse(mx+ibc,my+jbc,mq) = sum/kc
                 enddo
              enddo
           endif
        enddo
  
        end
  
  
  