function derivs = derivsL95(x,par,dim)

% Lorenz '95

% Lorenz, E. and K. Emanuel, 1998.  Optimal Sites for Supplementary 
% Weather Observations: Simulation with a Small Model, JAS, 55, 399-414.

% Equations
% \dot{x}_i = -x_{i-2}*x_{i-1} + x_{i-1}*x_{i+1} - x_{i} + f

for i=1:dim
 im1=i-1;
 if(i==1);im1=dim;end
 im2=i-2;
 if(im2<=0);im2=im2+dim;end
 ip1=i+1;
 if(i==dim);ip1=1;end
 derivs(i) = -x(im2)*x(im1) + x(im1)*x(ip1) - x(i) + par(i);
end
