anchor.diff:                  do j = 1, obj % ndims
                       oldIndex = inds(j)
                       ! periodic BCs
  -                    inds(j) = mod(inds(j) + obj % numCells(j) - 1, obj%numCells) + 1
  +                    inds(j) = mod(inds(j) + obj % numCells(j) - 1, obj % numCells(j)) + 1
                       
                       call upwind_getFlatIndex(obj, inds, upI)
                       
  
positive.code:         integer iunit, i
          
          open(newunit = iunit, file = filename, status = 'new')
          write(iunit, *) "# vtk DataFile Version 2.0"
          write(iunit, *) "upwind.cxx"
          write(iunit, *) "ASCII"
          write(iunit, *) "DATASET RECTILINEAR_GRID"
          write(iunit, *) "DIMENSIONS"
          ! in VTK the first dimension varies fastest so need 
          ! to invert the order of the dimensions
          if (NDIMS > 2) then
              write(iunit, *) ' ' << this->numCells[2] + 1
          else
              write(iunit, *) " 1"
          endif 
          
          if (NDIMS > 1) then
              write(iunit, *) ' ' << this->numCells[1] + 1
          else
              write(iunit, *) " 1"
          endif
          
          write(iunit, *) ' ' << this->numCells[0] + 1
          write(iunit, *) "X_COORDINATES "
          if (NDIMS > 2) then
              write(iunit, *) this->numCells[2] + 1 << " double"
              do i = 1: i < this->numCells[3] 
                  write(iunit, *) ' ' << 0.0 + this->deltas[2] * i
              enddo     
    
          else 
              write(iunit, *) "1 double"
              write(iunit, *) "0.0"
          endif
      
          write(iunit, *) "Y_COORDINATES "
          if (NDIMS > 1) then
              write(iunit, *) this->numCells[1] + 1 << " double"
              do i = 1:this->numCells[3] then
                  write(iunit, *) ' ' << 0.0 + this->deltas[1] * i
              enddo      
          else
              write(iunit, *) "1 double"
              write(iunit, *) "0.0"
          endif
        
          write(iunit, *) "Z_COORDINATES "
          write(iunit, *) this->numCells[0] + 1 << " double"
          do i = 1:this->numCells[1]
              write(iunit, *) ' ' << 0.0 + this->deltas[0] * i
          enddo
          write(iunit, *) "CELL_DATA " << this->ntot << ''
          write(iunit, *) "SCALARS f double 1"
          write(iunit, *) "LOOKUP_TABLE default"
          do i = 1:this->ntot
              write(iunit, *) this->f[i] << " "
              if (mod(i, 10) == 0) write(iunit, *) ''
          enddo
      
          close(iunit)
      
      end subroutine
  
      subroutine upwind_checksum(obj, res)
          type(upwind_type) :: obj
          real(r8), intent(out) :: res
          
          res = sum(obj % f)    
  
      end subroutine
  
      subroutine upwind_print(obj)
  
negative.code:         integer, intent(out) :: res(:)
      
          integer :: i
          do i = 1, obj % ndims
              res(i) = mod((flatIndex - 1)/obj % dimProd(i), obj % numCells(i)) + 1
          enddo
      end subroutine
      
  