anchor.diff:  
   c                       # Use areas of the fine grid mesh cells instead.
                           qcoarse(mq,ic,jc) = sum/af_sum
  -                        enddo
  +                     enddo
  +                  else
  +c                    sum = 0
  +                     do m = 0,r2-1
  +c                       sum = sum + qfine(mq,i2(m),j2(m))
  +c                       qcoarse(mq,ic,jc) = sum/dble(r2)
  +                        if (mcapa .eq. 0) then
  +                           capa=1.0d0
  +                        else
  +                           capa=aux_fine(mcapa,i2(m),j2(m))
  +                        endif
  +                        hf = qfine(1,i2(m),j2(m))*capa
  +                        bf = aux_fine(mbathy,i2(m),j2(m))*capa
  +                        huf= qfine(2,i2(m),j2(m))*capa
  +                        hvf= qfine(3,i2(m),j2(m))*capa
  +                        if (hf > dry_tolerance) then
  +                           etaf = hf+bf
  +                           nwet=nwet+1
  +                        else
  +                           etaf = 0.d0
  +                           huf=0.d0
  +                           hvf=0.d0
  +                        endif
  +                        hsum   = hsum + hf
  +                        husum  = husum + huf
  +                        hvsum  = hvsum + hvf
  +                        etasum = etasum + etaf
  +                     enddo
  +                     if (nwet.gt.0) then
  +                        etaav=etasum/dble(nwet)
  +                        hav=hsum/dble(nwet)
  +c                       hc=max(etaav-bc*capac,0.d0) !tsunamiclaw method
  +     &
  +                        hc=min(hav,(max(etaav-
  +     &                        aux_coarse(mbathy,ic,jc)*capac,0.d0)))
  +c                       huc=(min(hav,hc)/hsum)*husum
  +c                       hvc=(min(hav,hc)/hsum)*hvsum
  +                        huc=(hc/hsum)*husum
  +                        hvc=(hc/hsum)*hvsum
                        else
  -c                        sum = 0
  -                        do m = 0,r2-1
  -c                           sum = sum + qfine(mq,i2(m),j2(m))
  -c                           qcoarse(mq,ic,jc) = sum/dble(r2)
  -                           if (mcapa .eq. 0) then
  -                              capa=1.0d0
  -                           else
  -                              capa=aux_fine(mcapa,i2(m),j2(m))
  -                              endif
  -                           hf = qfine(1,i2(m),j2(m))*capa
  -                           bf = aux_fine(mbathy,i2(m),j2(m))*capa
  -                           huf= qfine(2,i2(m),j2(m))*capa 
  -                           hvf= qfine(3,i2(m),j2(m))*capa
  -                           if (hf > dry_tolerance) then
  -                              etaf = hf+bf
  -                              nwet=nwet+1
  -                           else
  -                              etaf = 0.d0
  -                              huf=0.d0
  -                              hvf=0.d0
  -                              endif
  -                           hsum   = hsum + hf
  -                           husum  = husum + huf
  -                           hvsum  = hvsum + hvf
  -                           etasum = etasum + etaf 
  -                           enddo          
  -                        if (nwet.gt.0) then
  -                           etaav=etasum/dble(nwet)
  -                           hav=hsum/dble(nwet)
  -            c              hc=max(etaav-bc*capac,0.d0) !tsunamiclaw method
  -                           hc=min(hav,(max(etaav-
  -                 &             aux_coarse(mbathy,ic,jc)*capac,0.d0)))
  -            c               huc=(min(hav,hc)/hsum)*husum
  -            c               hvc=(min(hav,hc)/hsum)*hvsum
  -                           huc=(hc/hsum)*husum
  -                           hvc=(hc/hsum)*hvsum
  -                        else
  -                           hc=0.d0
  -                           huc=0.d0
  -                           hvc=0.d0
  -                           endif      
  -                        qcoarse(1,ic,jc) = hc / capac 
  -                        qcoarse(2,ic,jc) = huc / capac 
  -                        qcoarse(3,ic,jc) = hvc / capac 
  -                        enddo
  +                        hc=0.d0
  +                        huc=0.d0
  +                        hvc=0.d0
                        endif
  +                     qcoarse(1,ic,jc) = hc / capac
  +                     qcoarse(2,ic,jc) = huc / capac
  +                     qcoarse(3,ic,jc) = hvc / capac
  +                  endif
  +               endif
  +            enddo
  +         enddo
  +      else
  +c        # idir = 1 (faces 2,3)
  +         do jbc = 1,mbc
  +            do ic = 1,mx
  +
  +               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
  +                           qf = qfine(mq,i2(m),j2(m))
  +                           kf = areafine(i2(m),j2(m))
  +                           sum = sum + qf*kf
  +                           af_sum = af_sum + kf
  +                        enddo
  +                        kc = areacoarse(ic,jc)
  +c                       qcoarse(mq,ic,jc) = sum/kc
  +                        qcoarse(mq,ic,jc) = sum/af_sum
  +                     enddo
  +                  else
  +                     sum = 0
  +                     do m = 0,r2-1
  +                        sum = sum + qfine(mq,i2(m),j2(m))
  +                     enddo
  +                     qcoarse(mq,ic,jc) = sum/dble(r2)
  +                  endif                 !! manifold loop
  +               endif                    !! skip grid loop
               enddo
  -        else
  -c           # idir = 1 (faces 2,3)
  -            do jbc = 1,mbc
  -               do ic = 1,mx
  -
  -                  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
  -                              qf = qfine(mq,i2(m),j2(m))
  -                              kf = areafine(i2(m),j2(m))
  -                              sum = sum + qf*kf
  -                              af_sum = af_sum + kf
  -                           enddo
  -                           kc = areacoarse(ic,jc)
  -   c                       qcoarse(mq,ic,jc) = sum/kc
  -                           qcoarse(mq,ic,jc) = sum/af_sum
  -                           enddo
  -                     else
  -                        sum = 0
  -                        do m = 0,r2-1
  -                           sum = sum + qfine(mq,i2(m),j2(m))
  -                        enddo
  -                        qcoarse(mq,ic,jc) = sum/dble(r2)
  -                     endif              !! manifold loop
  -                  endif                 !! skip grid loop
  -               enddo
  -            enddo
  +         enddo
         endif
   
         end
  
positive.code: 
  c     # Average fine grid onto coarse grid
        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
                    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
                                qf = qfine(mq,i2(m),j2(m))
                                qv(m) = qf
                                kf = areafine(i2(m),j2(m))
                                sum = sum + qf*kf
                                af_sum = af_sum + kf
                             enddo
  c                       # ----------------------------------------
  c                       # At block seams, the coarse grid mesh cell
  c                       # areas may not have been computed using
  
negative.code:       double precision hc, huc, hvc
        double precision hf, huf, hvf, bf, etaf
        double precision capac, capa
        integer nwet
  
        integer mbathy,mcapa
  
        mbathy = 1
        mcapa = 0
  
        is_manifold = manifold .eq. 1
  
  