Adjoint models are increasingly applied to many problems in meteorology and oceanography. The adjoint model of MM5 is a tool which effectively computes the gradient (or a Gateau-derivative) of any MM5 forecast aspect with respect to the model's control variables, which consist of model initial conditions, boundary conditions, and model parameters that define the physical and numerical conditions of the integration. Different applications of adjoint models in meteorology are briefly reviewed and their mathematical formulae are provided which illustrate how the adjoint model and/or tangent linear model are used in each application. Then we describe the mathematical and numerical formulation used in developing the adjoint version of MM5. The possibility of carrying out optimal control of lateral boundary condition in addition to the initial condition, the restart of minimization procedure, the proper handling of disk space for large problems, and the choice of different basic state update frequencies are provided. Finally, problems that might arise in the practical coding of the adjoint of a numerical model are summarized. A number of rules for the practical coding of tangent linear and adjoint models, along with various examples, are presented. The problems raised by the development and maintenance of adjoint codes are also discussed.