| 124 | The interface of the routine is identical for all filters. However, the particular operations that are performed in the routine can be specific for each filter algorithm. Here, we exemplify the interface on the example of the SEIK filter. |
| 125 | |
| 126 | The interface for this routine is |
| 127 | {{{ |
| 128 | SUBROUTINE prepoststep(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, & |
| 129 | state_p, Uinv, ens_p, flag) |
| 130 | |
| 131 | INTEGER, INTENT(in) :: step ! Current time step |
| 132 | ! (When the routine is called before the analysis -step is provided.) |
| 133 | INTEGER, INTENT(in) :: dim_p ! PE-local state dimension |
| 134 | INTEGER, INTENT(in) :: dim_ens ! Size of state ensemble |
| 135 | INTEGER, INTENT(in) :: dim_ens_p ! PE-local size of ensemble |
| 136 | INTEGER, INTENT(in) :: dim_obs_p ! PE-local dimension of observation vector |
| 137 | REAL, INTENT(inout) :: state_p(dim_p) ! PE-local forecast/analysis state |
| 138 | ! The array 'state_p' is not generally not initialized in the case of SEIK. |
| 139 | ! It can be used freely here. |
| 140 | REAL, INTENT(inout) :: Uinv(dim_ens-1, dim_ens-1) ! Inverse of matrix U |
| 141 | REAL, INTENT(inout) :: ens_p(dim_p, dim_ens) ! PE-local state ensemble |
| 142 | INTEGER, INTENT(in) :: flag ! PDAF status flag |
| 143 | }}} |
| 144 | |
| 145 | The routine `U_prepoststep` is called once at the beginning of the assimilation process. In addition, it is called during the assimilation cycles before the analysis step and after the ensemble transformation. The routine is called by all filter processes (that is `filterpe=1`). |
| 146 | |
| 147 | The routine provides for the user the full access to the ensemble of model states. Thus, user-controlled pre- and post-step operations can be performed. For example the forecast and the analysis states and ensemble covariance matrix can be analyzed, e.g. by computing the estimated variances. In addition, the estimates can be written to disk. |
| 148 | |
| 149 | Hint: |
| 150 | * If a user considers to perform adjustments to the estimates (e.g. for balances), this routine is the right place for it. |
| 151 | |
| 152 | |
| 153 | === `U_collect_state` (collect_state.F90) === |
| 154 | |
| 155 | The interface for this routine is |
| 156 | {{{ |
| 157 | SUBROUTINE collect_state(dim_p, state_p) |
| 158 | |
| 159 | INTEGER, INTENT(in) :: dim_p ! State dimension for PE-local model sub-domain |
| 160 | REAL, INTENT(inout) :: state_p(dim_p) ! State vector for PE-local model sub-domain |
| 161 | }}} |
| 162 | |
| 163 | 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 member state of the ensemble. The routine is executed by all processes that belong to model tasks. |
| 164 | |
| 165 | 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 `U_distribute_state`. That is, the state vector `state_p` has to be initialized from the model fields. If the model is not parallelized, `state_p` will contain a full state vector. If the model is parallelized using domain decomposition, `state_p` will contain the part of the state vector that corresponds to the model sub-domain for the calling process. |
| 166 | |
| 167 | Some hints: |
| 168 | * If the state vector does not include all model fields, it can be useful to keep a separate array to store those additional fields. This array has to be kept separate from PDAF, but can be defined using a module like `mod_assimilation`. |