19 | | Here we describe the extensions of the model code for the online mode of PDAF. The online mode offers two implementation variants. The first one, called ''fully-parallel'', assumes that you have a sufficient number of processes when running the data assimilation program so that all ensemble states can be propagated concurrently. The parallelism allows for a simplified implementation. The second implementation variant, called ''flexible'', allows to run the assimilation program in a way so that a model task (set of processors running one model integration) can propagate several ensemble states successively. This implementation variant is a bit more complicated, because one has to ensure that the model can jump back in time. |
| 19 | Here we describe the extensions of the model code for the online mode of PDAF. The online mode offers two implementation variants. The first one, called ''fully-parallel'', assumes that you have a sufficient number of processes when running the data assimilation program so that all ensemble states can be propagated concurrently. This parallelism allows for a simplified implementation. The second implementation variant, called ''flexible'', allows to run the assimilation program in a way so that a model task (set of processors running one model integration) can propagate several ensemble states successively. This implementation variant is a bit more complicated, because one has to ensure that the model can jump back in time. |
37 | 37 | * **init_pdaf**: This subroutine is added after the initialization part of the model, just before the time stepping loop. This this subroutine one defines parameters for PDAF and then one calls the core initialization routine `PDAF_init`. This core routine also initializes the array of ensemble states using a user-provided call-back routine. Subsequently, the PDAF-core routine `PDAF_init_forecast` is called (in implementations of PDAF before version 3.0, this routine was called `PDAF_get_state`). This routine initializes model fields from the array of ensemble states using a call-back routine. In addition it returns the the number of time steps that have to be computed in the following forecast phase. |
38 | 38 | * **assimilate_pdaf**: This routine is added to the model code at the end of the time stepping loop (usually just before the ''END DO'' in a Fortran program). The routine declares the names of user-supplied subroutines and calls a PDAF-core routine `PDAF3_assimilate`. (In implementations of PDAF before version 3.0, different routine named `PDAFomi_assimilate_X` with, e.g., X=`local`, for local filters are used). This routine has to be called at the end of each time step. It counts whether all time steps of the current forecast phase have been computed. If this is not the case, the program continues integrating the model. If the forecast phase is completed, the analysis step (i.e. the actual assimilation of the observations) is computed. Subsequently, the next forecast phase is initialized by writing the analysis state vector into the model fields and setting the number of time steps in the next forecast phase. |
82 | | * **Ensemble loop**: In order to allow for the integration of the state ensemble, an unconditional loop is added around the time stepping loop of the model. This loop will allow to compute the time stepping loop multiple times to integrate all ensemble states. PDAF provides an exit-flag for this loop. The number of time steps in the forecast (`nsteps`) is initially provided by `init_pdaf` and subsequently by `PDAF_get_fcst_info`. |
83 | | * **assimilate_pdaf**: Inside the ensemble loop, a call to this interface routine is added to the code. In this routine the names of user-supplied routines are declared and the PDAF-core routine `PDAF_assim_offline` is called. This routine initializes model fields from the array of ensemble states and initializes the number of time steps that have to be computed and ensures that the ensemble integration is performed correctly. |
84 | | * **put_state_pdaf**: At the end of the external loop, the call to the interface routine `put_state_pdaf` is added to the model code. The routine declares the names of user-supplied routines and calls a PDAF_core routine that is specific for the DA methods. E.g., the routine `PDAFomi_put_state_local` is called for the local ensemble Kalman filters. This routine writes the propagated model fields back into a state vector of the ensemble array. Also it checks whether the ensemble integration is complete. If not, the next ensemble member will be integrated. If the ensemble integration is complete, the analysis step (i.e. the actual assimilation of the observations) is computed. |
| 85 | * **Ensemble loop**: In order to allow for the integration of the state ensemble, an unconditional loop is added around the time stepping loop of the model. This loop will allow to compute the time stepping loop multiple times to integrate all ensemble states. PDAF provides an exit flag for this loop, which is checked to control when to exit this loop. The number of time steps in the forecast (`nsteps`) is initially provided by `init_pdaf` and subsequently by `PDAF_get_fcst_info`. |
| 86 | * **assimilate_pdaf**: Inside the ensemble loop, a call to this interface routine is added to the code in the same way as for the `fully parallel` mode. |
| 87 | * ** PDAF_get_fcst_info**: The analysis step is computed when the request number of time steps `steps` are completed. At this point the program steps out of the model time stepping loop. Here, a call to `PDAF_get_fcst_info` is used to obtain the number of time steps for the next forecast phase and the value of the exit flag. Subsequently, one checks the exit flag and when this indcates to end the assimilation process one steps out of the outer unconditional loop. Otherwise, the program continues with the next forecast phase. |
| 88 | * **finalize_pdaf**: This routine is optional. It is used to let PDAF display timing and memory information and to call PDAF to deallocate its internal arrays. |
| 89 | |
| 90 | A code example for the `flexible` mode is provided in the template codes in `templates/online_flexible/`. |