Changes between Version 34 and Version 35 of ModifyModelforEnsembleIntegration


Ignore:
Timestamp:
May 24, 2025, 8:41:08 AM (8 days ago)
Author:
lnerger
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ModifyModelforEnsembleIntegration

    v34 v35  
    2929
    3030[[Image(//pics/DAextension_PDAF3.png)]]
    31 [[BR]]'''Figure 1:''' (left) Generic structure of a model code, (right) modified structure for ''fully-parallel'' data assimilation system with PDAF. The figures assumes that the model is parallelized, such that it initializes its parallelization in the step `initial parallelization`. If the model is not parallelized this step does not exist.
     31[[BR]]'''Figure 1:''' (left) Generic structure of a model code, (right) modified structure for ''fully-parallel'' data assimilation system with PDAF. The figures assumes that the model is parallelized, such that it initializes its parallelization in the step `initial parallelization`. If the model is not parallelized this step does not exist. ''isteps'' is the total number of time steps in the assimialtion program.
    3232
    3333There are two further steps required now:
     
    4848}}}
    4949with the arguments (where the bold names show the arguments relevant to the user for the ''fully-parallel'' variant):
    50  * `nsteps`: An integer specifying upon exit the number of time steps to be performed
    51  * `timenow`: A real specifying upon exit the current model time.
    52  * `doexit`: An integer variable defining whether the assimilation process is completed. (1: exit, 0: continue).
    53  * **[#next_observation_pdafnext_observation_pdaf.F90 U_next_observation]**: The name of a user supplied routine that initializes the variables `nsteps`, `timenow`, and `doexit`
    54  * **[#distribute_state_pdafdistribute_state_pdaf.F90 U_distribute_state]**: The name of a user supplied routine that initializes the model fields from the array holding the ensemble of model state vectors
    55  * **[#prepoststep_pdafprepoststep_ens_pdaf.F90 U_prepoststep]**: The name of a user supplied routine that is called before and after the analysis step. Here the user has the possibility to access the state ensemble and can e.g. compute estimated variances or can write the ensemble states the state estimate into files.
    56  * **`status`**: The integer status flag. It is zero, if the routine is exited without errors. We recommend to check the value.
     50 * `nsteps`, `integer, intent(inout)`:[[BR]] The return value for the number of time steps to be performed
     51 * `timenow`, `real, intent(out)`:[[BR]] The current model time in a user-defined definition
     52 * `doexit`, `integer, intent(inout)`:[[BR]] The exit flag defining whether the assimilation process is completed. (1: exit, 0: continue).
     53 * **[#next_observation_pdafnext_observation_pdaf.F90 next_observation_pdaf]**:[[BR]] The name of a user supplied routine that initializes the variables `nsteps`, `timenow`, and `doexit`
     54 * **[#distribute_state_pdafdistribute_state_pdaf.F90 distribute_state_pdaf]**:[[BR]] The name of a user supplied routine that initializes the model fields from the array holding the ensemble of model state vectors
     55 * **[#prepoststep_pdafprepoststep_ens_pdaf.F90 prepoststep_pdaf]**:[[BR]] The name of a user supplied routine that is called before and after the analysis step. Here the user has the possibility to access the state ensemble and can e.g. compute estimated variances or can write the ensemble states the state estimate into files.
     56 * **`status`, `integer, intent(inout)`**:[[BR]] The status flag. It is zero, if the routine is exited without errors. We recommend to check the value.
    5757
    5858The user-supplied routines are described further below.
     
    7171Details on the implementations of the user-routines for the analysis step ar provided in the following [wiki:ImplementationofAnalysisStep Page on implementating the analysis step].
    7272
     73
     74
    7375== User-supplied routines ==
    7476
     
    7779In the section titles below we provide the name of the template file in parentheses.
    7880
     81
     82
    7983=== `next_observation_pdaf` (next_observation_pdaf.F90) ===
    8084
    81 The interface for this routine is
     85The interface is:
    8286{{{
    8387SUBROUTINE next_observation_pdaf(stepnow, nsteps, doexit, timenow)
     88}}}
     89with arguments:
     90* `stepnow`, `integer, intent(in)`:[[BR]] The current time step provided by PDAF
     91* `nsteps`, `integer, intent(out)`:[[BR]] The number of time steps of the next forecast phase
     92* `doexit`, `integer, intent(out)`:[[BR]] Exit flag: (1) exit, (0) continue data assimilation
     93* `timenow`, `real, intent(out)`:[[BR]] The current (physical) model time as defined by the model or user. Not used by PDAF itself.
    8494
    85   INTEGER, INTENT(in)  :: stepnow  ! The current time step
    86   INTEGER, INTENT(out) :: nsteps   ! Number of time steps until next obs
    87   INTEGER, INTENT(out) :: doexit   ! Whether to exit forecasting (1 for exit)
    88   REAL, INTENT(out)    :: timenow  ! Current model (physical) time (canbe defined freely by the user.
    89 }}}
     95The routine is called by `PDAF_init_forecast` and later at the beginning of each forecast phase by `PDAF3_assimilate`, or similar routines. It is executed by all processes that participate in the model integrations.
    9096
    91 The routine is called by Here, only the user-supplied routines are discussed that are required at this stage of the implementation (that is, the ensemble integration). For testing (see [#Compilationandtesting 'Compilation and testing']), all routines need to exist, but only those described here in detail need to be implemented with functionality.
     97For the ``fully parallel`` implementation variant, the main variable to be returned is the number of time steps in the next forecast phase.
    9298
    93 To indicate user-supplied routines we use the prefix `U_`. In the tutorials in `tutorial/` and in the template directory `templates/` these routines exist without the prefix, but with the extension `_pdaf`. The files are named correspondingly. In the section titles below we provide the name of the template file in parentheses.
    94 
    95 The user-supplied routines are in general identical for the 'fully parallel' and 'flexible' implementation variants. The only difference is in `U_next_observation` as is described below.
    96 
    97 === `U_next_observation` (next_observation_pdaf.F90) ===
    98 
    99 The interface for this routine is
    100 {{{
    101 SUBROUTINE next_observation(stepnow, nsteps, doexit, timenow)
    102 
    103   INTEGER, INTENT(in)  :: stepnow  ! Number of the current time step
    104   INTEGER, INTENT(out) :: nsteps   ! Number of time steps until next obs
    105   INTEGER, INTENT(out) :: doexit   ! Whether to exit forecasting (1 for exit)
    106   REAL, INTENT(out)    :: timenow  ! Current model (physical) time
    107 }}}
    108 
    109 The routine is called once at the beginning of each forecast phase. It is executed by all processes that participate in the model integrations.
    110 
    111 Based on the information of the current time step, the routine has to define the number of time steps `nsteps` for the next forecast phase. For the 'fully parallel' data assimilation variant the flag `doexit` is not used and does not need to be set. `timenow` is the current model time. However, for the 'fully parallel' data assimilation variant, this value is not relevant.
     99Based on the information of the current time step, the routine has to define the number of time steps `nsteps` for the next forecast phase. For the 'fully parallel' data assimilation variant, the flag `doexit` is only used inside PDAF.
    112100
    113101Some hints:
    114  * If the time interval between successive observations is known, `nsteps` can be simply initialized by dividing the time interval by the size of the time step
    115  * At the first call to `U_next_obs` the variable `timenow` can be initialized with the current model time. At the next call a forecast phase has been completed. Thus, the new value of `timenow` follows from the timer interval for the previous forecast phase.
    116  * `doexit` is not relevant for the fully-parallel implementation. It is recommended to set `doexit=0` in all cases.
    117  * If `nsteps=0` or `doexit=1` is set, the ensemble state will not be distributed by PDAF (thus `distribute_state` is not called). If one intends to proceed with ensemble forecasting, one has to set nsteps to a value >0 and `doexit=0`.  If nsteps is set to a value larger than the last time step of the model no further analysis step will be performed.
     102 * We assume that the time interval between successive observations is known. Then, `nsteps` can be simply initialized by dividing the time interval by the size of the time step.
     103 * It is up to the user to define `timenow` because it is only used in the user-code. The user can either ignore it (setting to to 0.0), or could use it freely to indicate the model time. At the first call to `next_observation_pdaf` the variable `timenow` can be initialized with the current model time. At the next call a forecast phase has been completed. Thus, the new value of `timenow` follows from the timer interval for the previous forecast phase and can be incremented accordingly.
     104 * In the ''fully-parallel'' implementation discussed here, `doexit` is not used in the user-code. One can safely just set it to 0.
     105 * `doexit` is used as follows inside PDAF. If `nsteps=0` or `doexit=1` is set, the ensemble state will not be distributed by PDAF (thus `distribute_state`, see below, is not called). If one intends to proceed with ensemble forecasting, one has to set `nsteps` to a value >0 and `doexit=0`. 
     106 * The total number of time steps set for the assimilation experiment (variable `isteps` in Fig. 1) defines when the model integrations end. If `nsteps` is set so that it specifies a time step larger than `isteps` not all of these steps will be computed.
    118107
    119 === `U_distribute_state` (distribute_state_pdaf.F90) ===
     108=== `distribute_state_pdaf` (distribute_state_pdaf.F90) ===
    120109
    121110The interface for this routine is
    122111{{{
    123112SUBROUTINE distribute_state(dim_p, state_p)
     113}}}
     114with arguments
     115 * `dim_p`, `integer, intent(in)`:[[BR]] Size of state vector for process-local sub-domain
     116 * `state_p`, `real, intent(in), dimension(dim_p)`:[[BR]] State vector for process-local sub-domain
    124117
    125   INTEGER, INTENT(in) :: dim_p           ! State dimension for PE-local model sub-domain
    126   REAL, INTENT(inout) :: state_p(dim_p)  ! State vector for PE-local model sub-domain
    127 }}}
     118The routine is called by `PDAF_init_forecast` and later at the beginning of each forecast phase by `PDAF3_assimilate`, or similar routines. It is executed by all processes that participate in the model integrations.
    128119
    129 This routine is called during the forecast phase as many times as there are states to be integrated by a model task. Again, the routine is executed by all processes that belong to model tasks.
    130 
    131 When the routine is called a state vector `state_p` and its size `dim_p` are provided. As the user has defined how the model fields are stored in the state vector, one can initialize the model fields from this information. 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.
     120PDAF calls this routine providing the state vector `state_p` and its size `dim_p`. The routine has to write the information from the state vector into the model field arrays.
    132121
    133122Some hints:
    134  * 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`.
     123 * The user has defined the setup of the state vector, so that it is know which model fields are stored at which position in the state vector and in which order, for example, a 3-dimensional model field is stored. This was already used in `init_ens_pdaf`.
     124 * The code usually consist of (nested) loops through each of the model fields, one field at a time. In the loop each element of the state vector is written into an element of a model field array.
     125 * 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.
    135126
    136127
    137 === `U_prepoststep` (prepoststep_ens_pdaf.F90) ===
    138 
    139 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 ESTKF and LESKTF filters.
     128=== `prepoststep_pdaf` (prepoststep_ens_pdaf.F90) ===
    140129
    141130The interface for this routine is
    142131{{{
    143132SUBROUTINE prepoststep(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, &
    144                        state_p, Uinv, ens_p, flag)
     133                       state_p, Ainv, ens_p, flag)
     134}}}
     135with arguments:
     136 * `step`, `INTEGER, INTENT(in)`:[[BR]] Current time step (When the routine is called for the forecast state the time steps is provided as a negative value.)
     137 * `dim_p`, `INTEGER, INTENT(in)`:[[BR]] Process-local state dimension
     138 * `dim_ens`, `INTEGER, INTENT(in)`:[[BR]] Ensemble size
     139 * `dim_ens_p`, `INTEGER, INTENT(in)`:[[BR]] Process-local ensemble size (not relevant for ''fully parallel'')
     140 * `dim_obs_p`, `INTEGER, INTENT(in)`:[[BR]] Process-local dimension of observation vector
     141 * `state_p`, `REAL, INTENT(inout), dimension(dim_p)`:[[BR]] Process-local state vector (The array 'state_p' is not generally not initialized. It can be used freely in this routine.)
     142 * `Ainv`, `REAL, INTENT(inout), dimension(dim_ens-1, dim_ens-1)`:[[BR]] Inverse of matrix A (only for special cases)
     143 * **`ens_p`, `REAL, INTENT(inout), dimension(dim_p, dim_ens)`**:[[BR]] State ensemble for process-local sub-domain
     144 * `flag`, `INTEGER, INTENT(in)`:[[BR]] PDAF status flag
    145145
    146   INTEGER, INTENT(in) :: step        ! Current time step
    147                          ! (When the routine is called before the analysis -step is provided.)
    148   INTEGER, INTENT(in) :: dim_p       ! PE-local state dimension
    149   INTEGER, INTENT(in) :: dim_ens     ! Size of state ensemble
    150   INTEGER, INTENT(in) :: dim_ens_p   ! PE-local size of ensemble
    151   INTEGER, INTENT(in) :: dim_obs_p   ! PE-local dimension of observation vector
    152   REAL, INTENT(inout) :: state_p(dim_p) ! PE-local forecast/analysis state
    153                                      ! The array 'state_p' is not generally not initialized.
    154                                      ! It can be used freely in this routine.
    155   REAL, INTENT(inout) :: Uinv(dim_ens-1, dim_ens-1) ! Inverse of matrix U
    156   REAL, INTENT(inout) :: ens_p(dim_p, dim_ens)      ! PE-local state ensemble
    157   INTEGER, INTENT(in) :: flag        ! PDAF status flag
    158 }}}
     146The routine `prepoststep_pdaf` 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=.true.`).
    159147
    160 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`).
     148With this routine, PDAF provides 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. If the smoother is used, also the smoothed ensembles can be analyzed. In addition, the estimates can be written to disk.
    161149
    162 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. If the smoother is used, also the smoothed ensembles can be analyzed. In addition, the estimates can be written to disk.
     150The routine also allows to perform adjustments to the state vectors, e.g. for balances, in the ensemble.
    163151
    164 Hint:
    165  * If a user considers to perform adjustments to the estimates (e.g. for balances), this routine is the right place for it.
    166  * Only for the SEEK filter the state vector (`state_p`) is initialized. For all other filters, the array is allocated, but it can be used freely during the execution of `U_prepoststep`.
    167  * The interface through which `U_prepoststep` is called does not include the array of smoothed ensembles. In order to access the smoother ensemble array one has to set a pointer to it using a call to the routine `PDAF_get_smootherens` (see page on [AuxiliaryRoutines auxiliary routines])Here, only the user-supplied routines are discussed that are required at this stage of the implementation (that is, the ensemble integration). For testing (see [#Compilationandtesting 'Compilation and testing']), all routines need to exist, but only those described here in detail need to be implemented with functionality.
    168 
    169 To indicate user-supplied routines we use the prefix `U_`. In the tutorials in `tutorial/` and in the template directory `templates/` these routines exist without the prefix, but with the extension `_pdaf`. The files are named correspondingly. In the section titles below we provide the name of the template file in parentheses.
    170 
    171 The user-supplied routines are in general identical for the 'fully parallel' and 'flexible' implementation variants. The only difference is in `U_next_observation` as is described below.
    172 
    173 === `next_observation_pdaf` (next_observation_pdaf.F90) ===
    174 
    175 The interface for this routine is
    176 {{{
    177 SUBROUTINE next_observation_pdaf(stepnow, nsteps, doexit, timenow)
    178 
    179   INTEGER, INTENT(in)  :: stepnow  ! Number of the current time step
    180   INTEGER, INTENT(out) :: nsteps   ! Number of time steps until next obs
    181   INTEGER, INTENT(out) :: doexit   ! Whether to exit forecasting (1 for exit)
    182   REAL, INTENT(out)    :: timenow  ! Current model (physical) time
    183 }}}
    184 
    185 The routine is called by `PDAF_init_forecast` and later at the beginning of each forecast phase. It is executed by all processes that participate in the model integrations.
    186 
    187 Based on the information of the current time step, the routine has to define the number of time steps `nsteps` for the next forecast phase. For the 'fully parallel' data assimilation variant the flag `doexit` is not used in the user code. `timenow` is the current model time. For the 'fully parallel' data assimilation variant, PDAF does not use this value. The user can either ignore it (setting to to 0.0), or could use it freely to indicate the model time.
    188 
    189 Some hints:
    190  * Usually, the time interval between successive observations is known. Then, `nsteps` can be simply initialized by dividing the time interval by the size of the time step.
    191  * At the first call to `next_observation_pdaf` the variable `timenow` can be initialized with the current model time. At the next call a forecast phase has been completed. Thus, the new value of `timenow` follows from the timer interval for the previous forecast phase and can be incremented accordingly
    192  * `doexit` is not relevant for the fully-parallel implementation. It is recommended to set `doexit=0` in all cases.
    193  * If `nsteps=0` or `doexit=1` is set, the ensemble state will not be distributed by PDAF (thus `distribute_state` is not called). If one intends to proceed with ensemble forecasting, one has to set nsteps to a value >0 and `doexit=0`.  If `nsteps` is set so that it specifies a time step larger than the last overall time step of the assimilation run, the numnber of time steps in the final forecast will be the total number of steps.
    194 
    195 === `U_distribute_state` (distribute_state_pdaf.F90) ===
    196 
    197 The interface for this routine is
    198 {{{
    199 SUBROUTINE distribute_state(dim_p, state_p)
    200 
    201   INTEGER, INTENT(in) :: dim_p           ! State dimension for PE-local model sub-domain
    202   REAL, INTENT(inout) :: state_p(dim_p)  ! State vector for PE-local model sub-domain
    203 }}}
    204 
    205 This routine is called during the forecast phase as many times as there are states to be integrated by a model task. Again, the routine is executed by all processes that belong to model tasks.
    206 
    207 When the routine is called a state vector `state_p` and its size `dim_p` are provided. As the user has defined how the model fields are stored in the state vector, one can initialize the model fields from this information. 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.
    208 
    209 Some hints:
    210  * 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`.
     152Hints:
     153 * The state vector, `state_p`, is usually not initialized because the ensemble DA methods focus on computing the ensemble and not its mean state. Thus the user would need to compute the ensemble mean, if this is required. This array can be used freely in `prepoststep_pdaf`.
     154 * The interface of `prepoststep_pdaf` does not include the array of smoothed ensembles. In order to access the smoother ensemble array, one has to set a pointer to it using a call to the routine `PDAF_get_smootherens` (see page on [AuxiliaryRoutines auxiliary routines]).
    211155
    212156
    213 === `U_prepoststep` (prepoststep_ens_pdaf.F90) ===
    214 
    215 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 ESTKF and LESKTF filters.
    216 
    217 The interface for this routine is
    218 {{{
    219 SUBROUTINE prepoststep(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, &
    220                        state_p, Uinv, ens_p, flag)
    221 
    222   INTEGER, INTENT(in) :: step        ! Current time step
    223                          ! (When the routine is called before the analysis -step is provided.)
    224   INTEGER, INTENT(in) :: dim_p       ! PE-local state dimension
    225   INTEGER, INTENT(in) :: dim_ens     ! Size of state ensemble
    226   INTEGER, INTENT(in) :: dim_ens_p   ! PE-local size of ensemble
    227   INTEGER, INTENT(in) :: dim_obs_p   ! PE-local dimension of observation vector
    228   REAL, INTENT(inout) :: state_p(dim_p) ! PE-local forecast/analysis state
    229                                      ! The array 'state_p' is not generally not initialized.
    230                                      ! It can be used freely in this routine.
    231   REAL, INTENT(inout) :: Uinv(dim_ens-1, dim_ens-1) ! Inverse of matrix U
    232   REAL, INTENT(inout) :: ens_p(dim_p, dim_ens)      ! PE-local state ensemble
    233   INTEGER, INTENT(in) :: flag        ! PDAF status flag
    234 }}}
    235 
    236 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`).
    237 
    238 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. If the smoother is used, also the smoothed ensembles can be analyzed. In addition, the estimates can be written to disk.
    239 
    240 Hint:
    241  * If a user considers to perform adjustments to the estimates (e.g. for balances), this routine is the right place for it.
    242  * Only for the SEEK filter the state vector (`state_p`) is initialized. For all other filters, the array is allocated, but it can be used freely during the execution of `U_prepoststep`.
    243  * The interface through which `U_prepoststep` is called does not include the array of smoothed ensembles. In order to access the smoother ensemble array one has to set a pointer to it using a call to the routine `PDAF_get_smootherens` (see page on [AuxiliaryRoutines auxiliary routines])once at the beginning of each forecast phase. It is executed by all processes that participate in the model integrations.
    244 
    245 Based on the information of the current time step, the routine has to define the number of time steps `nsteps` for the next forecast phase. For the 'fully parallel' data assimilation variant the flag `doexit` is not used and does not need to be set. `timenow` is the current model time. However, for the 'fully parallel' data assimilation variant, this value is not relevant.
    246 
    247 Some hints:
    248  * If the time interval between successive observations is known, `nsteps` can be simply initialized by dividing the time interval by the size of the time step
    249  * At the first call to `U_next_obs` the variable `timenow` can be initialized with the current model time. At the next call a forecast phase has been completed. Thus, the new value of `timenow` follows from the timer interval for the previous forecast phase.
    250  * `doexit` is not relevant for the fully-parallel implementation. It is recommended to set `doexit=0` in all cases.
    251  * If `nsteps=0` or `doexit=1` is set, the ensemble state will not be distributed by PDAF (thus `distribute_state` is not called). If one intends to proceed with ensemble forecasting, one has to set nsteps to a value >0 and `doexit=0`.  If nsteps is set to a value larger than the last time step of the model no further analysis step will be performed.
    252 
    253 === `U_distribute_state` (distribute_state_pdaf.F90) ===
    254 
    255 The interface for this routine is
    256 {{{
    257 SUBROUTINE distribute_state(dim_p, state_p)
    258 
    259   INTEGER, INTENT(in) :: dim_p           ! State dimension for PE-local model sub-domain
    260   REAL, INTENT(inout) :: state_p(dim_p)  ! State vector for PE-local model sub-domain
    261 }}}
    262 
    263 This routine is called during the forecast phase as many times as there are states to be integrated by a model task. Again, the routine is executed by all processes that belong to model tasks.
    264 
    265 When the routine is called a state vector `state_p` and its size `dim_p` are provided. As the user has defined how the model fields are stored in the state vector, one can initialize the model fields from this information. 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.
    266 
    267 Some hints:
    268  * 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`.
    269 
    270 
    271 === `U_prepoststep` (prepoststep_ens_pdaf.F90) ===
    272 
    273 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 ESTKF and LESKTF filters.
    274 
    275 The interface for this routine is
    276 {{{
    277 SUBROUTINE prepoststep(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, &
    278                        state_p, Uinv, ens_p, flag)
    279 
    280   INTEGER, INTENT(in) :: step        ! Current time step
    281                          ! (When the routine is called before the analysis -step is provided.)
    282   INTEGER, INTENT(in) :: dim_p       ! PE-local state dimension
    283   INTEGER, INTENT(in) :: dim_ens     ! Size of state ensemble
    284   INTEGER, INTENT(in) :: dim_ens_p   ! PE-local size of ensemble
    285   INTEGER, INTENT(in) :: dim_obs_p   ! PE-local dimension of observation vector
    286   REAL, INTENT(inout) :: state_p(dim_p) ! PE-local forecast/analysis state
    287                                      ! The array 'state_p' is not generally not initialized.
    288                                      ! It can be used freely in this routine.
    289   REAL, INTENT(inout) :: Uinv(dim_ens-1, dim_ens-1) ! Inverse of matrix U
    290   REAL, INTENT(inout) :: ens_p(dim_p, dim_ens)      ! PE-local state ensemble
    291   INTEGER, INTENT(in) :: flag        ! PDAF status flag
    292 }}}
    293 
    294 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`).
    295 
    296 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. If the smoother is used, also the smoothed ensembles can be analyzed. In addition, the estimates can be written to disk.
    297 
    298 Hint:
    299  * If a user considers to perform adjustments to the estimates (e.g. for balances), this routine is the right place for it.
    300  * Only for the SEEK filter the state vector (`state_p`) is initialized. For all other filters, the array is allocated, but it can be used freely during the execution of `U_prepoststep`.
    301  * The interface through which `U_prepoststep` is called does not include the array of smoothed ensembles. In order to access the smoother ensemble array one has to set a pointer to it using a call to the routine `PDAF_get_smootherens` (see page on [AuxiliaryRoutines auxiliary routines])