c     ============================================
      subroutine setaux(maxmx,maxmy,mbc,mx,my,xlower,ylower,dx,dy,
     &                  maux,aux)
c     ============================================
      implicit none

      integer maxmx, maxmy, mbc, mx,my, maux
      double precision xlower, ylower, dx,dy
      integer maxlevel, level, refratios(20), mcapa
      integer i,j, ij

      double precision locz, locc, bulk1, bulk2, xlow, ylow
      double precision c1, c2, rho1, rho2, bulk, rho, wl
      double precision xp, yp, xc,yc
      double precision kappa_max, kappa_min, kappa_avg
      integer mapped_mbc(4)

      double precision aux(1-mbc:maxmx+mbc,1-mbc:maxmy+mbc,maux)

c     # These should be set EITHER in driver.f (for a single grid
c     # CLAWPACK run), or by the calling AMR routine.  These common
c     # blocks are set automatically for ChomboClaw.  They are not
c     # set for amrclaw.
c     # refratios(l) = refinement ratio between level l and level l+1.
      common /comlevel/ maxlevel, level, refratios

      mcapa = 7
      do i = 1,4
c        # Calling mapc2p for both ghost cells (mbc=2)
         mapped_mbc(i) = 2
      enddo

      call setquadinfo(maxmx, maxmy, mbc,mx,my,xlower,ylower,
     &      dx,dy,maxlevel,level,refratios,mcapa,
     &      mapped_mbc, maux, aux)

      kappa_max = 0
      kappa_min = 100
      kappa_avg = 0;
      do j = 1,my
         ylow = ylower + (j-0.5)*dy
         do i = 1,mx
            xlow = xlower + (i-0.5)*dx
c           # r=x value needed for axis-symmetric source term.
            call mapc2p(xlow,ylow,xp,yp)
            aux(i,j,8) = xp
            kappa_max = max(aux(i,j,mcapa),kappa_max)
            kappa_min = min(aux(i,j,mcapa),kappa_min)
            kappa_avg = kappa_avg + aux(i,j,mcapa)
         enddo
      enddo

      write(6,'(A,F16.8)') 'Max kappa : ', kappa_max
      write(6,'(A,F16.8)') 'Min kappa : ', kappa_min
      write(6,'(A,F16.8)') 'Avg kappa : ', kappa_avg/(mx*my)
      write(6,'(A,F16.8)') 'Ratio     : ', kappa_max/kappa_min
      write(6,*) ' '

      end
