anchor.diff:  use params
   use like
   use priors
  -use array_utils, only: linspace, get_diagonal
  +use array_utils, only: linspace, get_diagonal, sort
   use gputils
      
   implicit none
  
positive.code: 		integer context ! any additional information user wants to pass
  		logical ending ! is this the final call?
  		! local variables
  		double precision, dimension(1000) :: t, mu, std
  		double precision, dimension(1000, 1000) :: cov
  		character(len=100) gppredictfile
  		integer i, map_index
  		character(len=100) :: fmt
  
  		! now do something
  		!if (doing_debug) write(*,*) paramConstr(nPar*3+1:nPar*4-2)
  		write(fmt,'(a,i2,a)')  '(',nPar,'f13.4)'
  		write(*,fmt) paramConstr(nPar*3+1:nPar*4)
  		!print *, ending, using_gp
  
  		if (ending .and. using_gp) then
  			gppredictfile = TRIM(nest_root)//'gp.dat'
  
  			t = linspace(minval(times), maxval(times), 1000)
  
  			!! set hyperparameters to their MAP values
  			map_index = nPar*3 ! this is where the MAP parameters start in the array
  
negative.code: 			!write(*, '(10f13.6)') gp1%gp_kernel%evaluate_kernel(times, times)
  			!print *, ''
  
  			write(*,*) 'Calculating predictions...'
  			call gp1%predict(times, rvs, paramConstr(nPar*3+1:nPar*4-4), t, mu, cov, yerr=errors)
  			std = sqrt(get_diagonal(cov))
  
  			write(*,*) 'Writing file ', gppredictfile
  			open(unit=59, file=gppredictfile, form='formatted', status='replace')
  			write(59, '(3f16.4)') (t(i), mu(i), std(i), i=1, size(times) + 1000)
  			close(59)
  
  		end if
  