anchor.diff:      call HYPRE_StructMatrixInitialize(hypre_A, ierr)
   
       nentries = 5 ! a five point stncil means five entries for each grid point
  -    nvalues = nx * ny ! total number of grid points to simulate
  +    nvalues = nx * ny * 5 ! total number of grid points to simulate * five stencil entries per grid point
       allocate(values(nvalues))
   
  -    do i = 1, nvalues, nentries ! loop over every grid point, skipping by the number of points in the stencil. This 
  +    do i = 1, nx !values, nentries ! loop over every grid point, skipping by the number of points in the stencil. This 
       ! selects only the central points of the stencil
  -    
  +      do j = 1, ny
  +
  +
       ! the 2D array is being laid out like
       ! [x1y1, x1y2, x1y3, x2y1, x2y2, x2y3, x3y1, x3y2, x3y3]
  -      values(i) = 1
  -    end do
  -
  +      values( ((i-1)*nx + j)*5 )    = a(5,i,j)
  +      values( ((i-1)*nx + j)*5 + 1) = a(3,i,j)
  +      values( ((i-1)*nx + j)*5 + 2) = a(1,i,j)
  +      values( ((i-1)*nx + j)*5 + 3) = a(4,i,j)
  +      values( ((i-1)*nx + j)*5 + 4) = a(2,i,j)
  +
  +      end do
  +    end do
  +
  +    do i = 0, num_procs-1
  +      call HYPRE_StructMatrixSetBoxValues(hypre_A, & 
  +        ilower(i,:), iupper(i,:), 5, stencil_indices, & 
  +        values, ierr)
  +    end do
  +
  +    call HYPRE_StructMatrixAssemble(hypre_A, ierr)
   #endif
   
       ! Check that the supplied free surface anomaly and layer
  
positive.code:     spongeHTimeScale, spongeUTimeScale, spongeVTimeScale, &
      spongeH, spongeU, spongeV, &
      nx, ny, layers, RedGrav, DumpWind, &
      MPI_COMM_WORLD, hypre_grid)
    implicit none
  
    ! Layer thickness (h)
  
negative.code:       spongeHTimeScale, spongeUTimeScale, spongeVTimeScale, &
        spongeH, spongeU, spongeV, &
        nx, ny, layers, RedGrav, DumpWind, &
        MPI_COMM_WORLD, num_procs, ilower, iupper, &
        hypre_grid)
    print *, 'Execution ended normally'
    stop 0
  end program aronnax
  