= Implementation Concept of the Offline Mode =
== Offline mode: Separating model integrations and assimilation step ==
{{{
#!html
}}}
[[PageOutline(2-3,Contents of this page)]]
In case of the offline mode of PDAF, the ensemble integrations are performed by the numerical model without required changes. After all ensemble members are integrated to the time when observations are to be assimilated, the assimilation program containing PDAF is started. The program reads the files from the model for all ensemble members. Subsequently, the analysis step of the chosen filter algorithm is computed. Finally, the updated ensemble states are written into input or restart files of the model. This completes the analysis step such that the next forecast phase can be computed.
In the forecast phase the user has to run the numerical model as many times as there are ensemble members. Each model forecast has to be initialized by the state fields of the ensemble member. At the end of each single forecast integration the forecast fields are written into regular output files of the model. Within the offline mode of PDAF, we leave it to the user to control the integrations. As these are regular model integrations, it should be easiest to use the regular scripts used also to perform a free model integration without data assimilation. However, the user has to take care that the output files from each ensemble member are stored separately.
The assimilation program is a simplified implementation of what is required when PDAF is used in its online mode. In particular, no explicit linkage to the model code and no forecast phase are required. The general structure of the program for the offline assimilation program is depicted in figure 1.
[[Image(//pics/PDAF_offline.png)]]
[[BR]]'''Figure 1:''' Structure of the assimilation program with PDAF in offline mode.
The structure of the assimilation program is the following:
* At the beginning of the program, the routine `init_parallel_pdaf` is executed. `init_parallel_pdaf` creates the parallel environment for PDAF. In the offline mode, it is possible to execute the assimilation program on a single processor, even if the model is parallelized.
* Subsequently, a routine `init_pdaf` is executed. In this routine, parameters for PDAF can be defined and then the core initialization routine `PDAF_init` is called. This core routine also initializes the array of ensemble states. In case of the offline mode, this means that the ensemble is read from the output files of the model.
* Finally, the PDAF core routine `PDAF_put_state` is executed. As for the offline mode there is no ensemble integration in the assimilation program, this subroutine directly computes the analysis step (i.e. the actual assimilation of the observations). In a user-supplied subroutine of `PDAF_put_state`, the ensemble of analysis states is finally written into restart files for the next forecast phase conducted by direct model integrations initialized from these files.
== Important aspects of the implementation concept ==
* With the offline mode of PDAF, no direct coupling between PDAF and the model code is required. The exchange of information between the model and the assimilation program is performed solely through the output and restart files of the model. It requires that the user implements routines to read the model fields from the forecast files. In addition, routines are necessary that write the analysis state ensemble into restart files of the model.
* Model-specific operations like the initialization of the array of ensemble states in `PDAF_init` are actually performed by user-supplied routines. These routines are called through the standard interface of `PDAF`. Details on the interface and the required routines are given on the pages describing the implementation steps.
* With regard to the parallelization, the assimilation program can be run on a single processor, i.e. without parallelization. The variables for the parallelization still have to be initialized by a call to `init_parallel_pdaf`. However, one does not need to compile with an MPI library, but it is sufficient to use the dummy implementation of the MPI-routines that is supplied with PDAF. If the model is parallelized, one needs to ensure that the model fields are read correctly. In particular, if in the parallel model each process writes a separate file, one has to read these files sequentially in order to initialize an ensemble array holding the global state information.
* For large-scale models, it can be useful to execute the assimilation program with parallelization. Perhaps, following the domain decomposition of the model is the easiest strategy for this. In this case the decomposition information from the model has to be read into the assimilation program in order to initialize the state dimension of the sub-domains as well as the coordinates for each sub-domain.
* The core routines of PDAF (those with the prefix `PDAF_`) are identical for the online and offline modes. The offline mode is switched on by selecting the corresponding subtype of the filter method in the call to `PDAF_init`.