= Modification of the model code for the ensemble integration = [[PageOutline(2-3)]] == Overview == Numerical models are typically implemented for normal integration of some initial state. For the data assimilation with filter algorithm, an ensemble of model states has to be integrated for limited time until observations are available and an analysis step of the filter is computed. Subsequently, the updated ensemble has to be integrated again. To allow for these alternating ensemble integrations and analysis steps the model code has to be extended. The recommended implementation strategy for PDAF is to add an additional loop outside of the regular time-stepping loop of the model. This strategy has the potential to reduce the required chances in the model code to the minimum. The required extensions are described below. == External ensemble loop == The external loop for the ensemble integration has to enclose the time stepping loop of the model. Next to the external loop, two calls to subroutines of PDAF have to be added. These are the calls to `PDAF_get_state` and a filter-specific routine like `PDAF_put_state_seik` for the SEIK filter. Both routines are described in sections below. {{{ pdaf_modelloop: DO CALL PDAF_get_state(nsteps, timenow, doexit, ..., status) ! Check whether forecast has to be performed ifcontrol: IF (doexit /= 1) THEN IF (nsteps > 0) THEN ... Time stepping code of the model ... END IF CALL PDAF_put_state_seik(collect_state, ..., status) ELSE ifcontrol EXIT pdaf_modelloop END IF ifcontrol END DO pdaf_modelloop }}}