55 | | This example is taken from the example implementation in `templates/online_flexible/`. The unconditional DO loop (while loop) allows for an arbirary number of repetitions. The exit of the loop is controlled by the exit flag `doexit`, which is obtained from `PDAF_get_fcst_info`. The variable `nsteps`, also obtained from PDAF_get_fcst_info, defines the number of time steps to be computed during the current forecast phase. This value has to be used in the model time stepping loop. |
56 | | |
57 | | The code changes for the ''flexible'' parallelization variant can usually be obtained by adapting the code for the ''fully parallel'' implementation variant. |
58 | | |
59 | | Apart from the changes described above we need to initialize the ensemble forecasting as in the ''fully parallel'' variant. In particular , we need to write the ensemble state vector values into the model fields. We need to set for PDAF how many time steps need to be done until the first observations are assimilated. For these operations, we call the routine `PDAF_init_forecast` in the routine `init_pdaf`. This call is identical to that used in the ''fully parallel' variant. |
| 55 | This example is taken from the template implementation in `templates/online_flexible/`. The unconditional DO loop (while loop) allows for an arbirary number of repetitions. The exit of the loop is controlled by the exit flag `doexit`, which is obtained from `PDAF_get_fcst_info`. The variable `nsteps`, also obtained from PDAF_get_fcst_info, defines the number of time steps to be computed during the current forecast phase. This value has to be used in the model time stepping loop. |
| 56 | |
| 57 | To complete the forecasting there are four further steps required: |
| 58 | 1. We need to initialize the ensemble forecasting. Thus, we need to set how many time steps need to be done until the first observations are assimilated. In addition, we need to write the ensemble state vector values into the model fields. For these operations, we call the routine `PDAF_init_forecast` in the routine `init_pdaf`. |
| 59 | 1. We need to adapt for model code for the additional ensemble loop and related control structure with calling `PDAF_get_fcst_info` as described above. |
| 60 | 1. To enable that the analysis can be performed, we then have to insert the routine `assimilate_pdaf` into the model code. |
| 61 | 1. To be able to test whether the forecasting works correctly we also recommend to implement the routine `collect_state_pdaf` at this point. The routine is used in `assimilate_pdaf` to write the forecasted model fields into a state vector. |
| 62 | |
| 63 | These steps are described below. The code changes for the ''flexible'' parallelization variant can usually be obtained by adapting the code for the ''fully parallel'' implementation variant. |
| 111 | Relevant for the forecasting is that `PDAF3_assimilate` calls the user-supplied routine `collect_state_pdaf` which writes forecasted model fields into a state vector from PDAF's ensemble array. We recommend to implement the functionality in `collect_state_pdaf` at this point, even though we explain `PDAF3_assimilation` only later. |
| 112 | |
| 113 | == Completing `collect_state_pdaf` == |
| 114 | |
| 115 | The routine `collect_state_pdaf` (In file collect_state_pdaf.F90 in the tutorials and template), is called during the forecast phase for each state vector of the ensemble to write the forecasted model fields back into a state vector. This is the reserve operation to what is done in `distribute_state_pdaf`. The routine is executed by all processes that belong to model tasks. |
| 116 | |
| 117 | The full interface of this call-back routine is explained further below with the other user-supplied routines. When the functionality is implemented, one can test the forecasting. In particular one can already test funtionality in `prepoststep_pdaf` because PDAF will provide this routine with the ensemble array that was filled with the information from model fields by calls to `collect_state_pdaf`. |
190 | | == Compiling and testing == |
191 | | |
192 | | To be able to test the ensemble forecasting, we need also need the user-supplied routine `collect_state_pdaf`. This routine writes the model fields after a forecast into the state vectors. This will be done in the call to `PDAF3_assimilate` in `assimilate_pdaf`. While we explain `assimilate_pdaf` on the following page, we include `collect_state_pdaf` here. |
193 | | |
194 | | Having implemented also `collect_state_pdaf`, one can test the program without having implemented the actual assimilation step. In the template code `template/online` all required user-supplied routines are included, but they don't contain functionality. However, one can use them to be able to compile and run the assimilation program for testing. In particular one can check if the ensemble forecasting works correctly. |
195 | | |
196 | | == `collect_state_pdaf` (collect_state_pdaf.F90) == |
| 201 | |
| 202 | === `collect_state_pdaf` (collect_state_pdaf.F90) === |
206 | | This routine is called during the forecast phase as many times as there are states to be integrated by a model task. It is called at the end of the integration of a state from the ensemble. The routine is executed by all processes that belong to model tasks. |
207 | | |
208 | | When the routine is called, a state vector `state_p` and its size `dim_p` are provided. The operation to be performed in this routine is inverse to that of the routine `distribute_state_pdaf`. That is, the state vector `state_p` has to be filled from the model fields. |
| 212 | The routine is called by `PDAF3_assimilate`, or similar assimilate routine, for each ensemble state for which a forecast was computed . It is executed by all processes that participate in the model integrations. |
| 213 | |
| 214 | PDAF calls this routine providing the state vector `state_p` and its size `dim_p`. The routine has to write the information from the model fields into this state vector. This is the reverse operation to that of the routine `distribute_state_pdaf`. |