anchor.diff:        endif
   
   c     # Average fine grid onto coarse grid
  -      do mq = 1,meqn
  -         if (idir .eq. 0) then
  -            do jc = 1,my
  -               do ibc = 1,mbc
  -c                 # ibc = 1 corresponds to first layer of ghost cells, and
  -c                 # ibc = 2 corresponds to the second layer
  -
  -                  if (iface_coarse .eq. 0) then
  -                     ic = 1-ibc
  -                  elseif (iface_coarse .eq. 1) then
  -                     ic = mx+ibc
  +      if (idir .eq. 0) then
  +         do jc = 1,my
  +            do ibc = 1,mbc
  +c              # ibc = 1 corresponds to first layer of ghost cells, and
  +c              # ibc = 2 corresponds to the second layer
  +
  +               if (iface_coarse .eq. 0) then
  +                  ic = 1-ibc
  +               elseif (iface_coarse .eq. 1) then
  +                  ic = mx+ibc
  +               endif
  +
  +               call fclaw2d_transform_face_half(ic,jc,i2,j2,
  +     &               transform_cptr)
  +c              # ---------------------------------------------
  +c              # Two 'half-size' neighbors will be passed into
  +c              # this routine.  Only half of the coarse grid ghost
  +c              # indices will be valid for the particular grid
  +c              # passed in.  We skip those ghost cells that will
  +c              # have to be filled in by the other half-size
  +c              # grid.
  +c              # ---------------------------------------------
  +               skip_this_grid = .false.
  +               do m = 0,r2-1
  +                  if (.not. is_valid_average(i2(m),j2(m),mx,my))
  +     &                  then
  +                     skip_this_grid = .true.
  +                     exit
                     endif
  -
  -c                 # New code
  -                  call fclaw2d_transform_face_half(ic,jc,i2,j2,
  -     &                  transform_cptr)
  -c                 # ---------------------------------------------
  -c                 # Two 'half-size' neighbors will be passed into
  -c                 # this routine.  Only half of the coarse grid ghost
  -c                 # indices will be valid for the particular grid
  -c                 # passed in.  We skip those ghost cells that will
  -c                 # have to be filled in by the other half-size
  -c                 # grid.
  -c                 # ---------------------------------------------
  -                  skip_this_grid = .false.
  -                  do m = 0,r2-1
  -                     if (.not. is_valid_average(i2(m),j2(m),mx,my))
  -     &                     then
  -                        skip_this_grid = .true.
  -                        exit
  -                     endif
  -                  enddo
  -
  -                  if (.not. skip_this_grid) then
  -                     if (is_manifold) then
  +               enddo
  +
  +               if (.not. skip_this_grid) then
  +                  if (is_manifold) then
  +                     do mq = 1,meqn
                           sum = 0
                           af_sum = 0
                           do m = 0,r2-1
  
positive.code:                      af_sum = af_sum + kf
                    enddo
                    kc = areacoarse(i1,j1)
  c                  qcoarse(i1,j1,mq) = sum/kc
                    qcoarse(i1,j1,mq) = sum/af_sum
                 else
                    sum = 0
                    do m = 0,r2-1
                       sum = sum + qfine(i2(m),j2(m),mq)
                    enddo
                    qcoarse(i1,j1,mq) = sum/dble(r2)
                 endif
  
  
              enddo
           enddo
        enddo
  
  
        end
  
negative.code: 
  c                       # Use areas of the fine grid mesh cells instead.
                          qcoarse(ic,jc,mq) = sum/af_sum
                       enddo
                    else
                       do mq = 1,meqn
                          sum = 0
                          do m = 0,r2-1
                             sum = sum + qfine(i2(m),j2(m),mq)
                          enddo
                          qcoarse(ic,jc,mq) = sum/dble(r2)
                       enddo
                    endif
                 endif
              enddo
           enddo
        else
  c        # idir = 1 (faces 2,3)
           do ic = 1,mx
              do jbc = 1,mbc
  
                 if (iface_coarse .eq. 2) then
                    jc = 1-jbc
                 elseif (iface_coarse .eq. 3) then
                    jc = my+jbc
                 endif
  
                 call fclaw2d_transform_face_half(ic,jc,i2,j2,
       &               transform_cptr)
                 skip_this_grid = .false.
                 do m = 0,r2-1
                    if (.not. is_valid_average(i2(m),j2(m),mx,my))
       &                  then
                       skip_this_grid = .true.
                    endif
                 enddo
                 if (.not. skip_this_grid) then
                    if (is_manifold) then
                       do mq = 1,meqn
                          sum = 0
                          af_sum = 0
                          do m = 0,r2-1
  