This report gives a brief introduction to data assimilation, and a summary of the calculus of variations and its application to optimal control theory. It then considers how data assimilation can be expressed as an optimal control problem. An algorithm is described for the numerical solution of the optimal control problem, which involves using the model and its adjoint to nd the gradient of the cost functional. This gradient is then used in a descent algorithm to produce an improved estimate of the control variable. The algorithm is tested for a simple ODE and a simple PDE model. For each model di erent discretisations are considered, and the corresponding discrete adjoint equations are found directly.