= Implementing the Analysis Step specific for global filters and LEnKF =
{{{
#!html
}}}
[[PageOutline(2-3,Contents of this page)]]
== Overview ==
This page describes the recommended implementation of the analysis step specific for global ensemble filters and LEnKF (Thus the filters: ESTKF, ETKF, SEIK, EnKF, NETF, PF, and LEnKF).
|| We recommend to only use this variant if one only runs global filters. As soon as one also intends to use local filters, like the LESTKF or LETKF, we recommend to use the [wiki:ImplementAnalysisPDAF3Universal implementation using the using the universal routines of the PDAF3 interface]. ||
The PDAF3 routines for the analysis step only distinguish whether the online or offline mode is used.
For the analysis step we need different operations related to the observations. These operations are requested by PDAF by call-back routines supplied by the user and provided in the observation modules using PDAF-OMI. The names of the routines that are provided by the user are specified in the call to the assimilation routine `PDAF3_assimilate`.
For completeness we discuss here all user-supplied routines that are specified as arguments in the assimilation routines.
== Assimilation routines ==
=== `PDAF3_assimilate_global` ===
This routine is used both in the ''fully-parallel'' and the ''flexible'' implementation variants of the data assimilation system. (See the page [ModifyModelforEnsembleIntegration Modification of the model code for the ensemble integration] for these variants)
Here, we list the full interface of the routine. Subsequently, the user-supplied routines specified in the call are explained.
The unversal interface is the following:
{{{
SUBROUTINE PDAF3_assimilate_global(collect_state_pdaf, distribute_state_pdaf, &
init_dim_obs_pdafomi, obs_op_pdafomi, &
prepoststep_pdaf, next_observation_pdaf, status)
}}}
with the following arguments:
* Routines to transfer between model fields and state vector:
* [#collect_state_pdafcollect_state_pdaf.F90 collect_state_pdaf]:[[BR]] The name of the user-supplied routine that initializes a state vector from the array holding the ensemble of model states from the model fields.
* [#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. (The same routine is also used in `PDAF_init_forecast`.)
* Observation routines using PDAF-OMI:
* [#init_dim_obs_pdafomicallback_obs_pdafomi.F90 init_dim_obs_pdafomi]:[[BR]] The name of the user-supplied routine that initializes the observation information and provides the size of observation vector
* [#obs_op_pdafomicallback_obs_pdafomi.F90 obs_op_pdafomi]:[[BR]] The name of the user-supplied routine that acts as the observation operator on some state vector
* Prepoststep and initialization for next forecast phase
* [#prepoststep_pdafprepoststep_ens_pdaf.F90 prepoststep_pdaf]:[[BR]] The name of the pre/poststep routine as in `PDAF_init_forecast`. (The same routine is also used in `PDAF_init_forecast`.)
* [#next_observation_pdafnext_observation.F90 next_observation_pdaf]:[[BR]] The name of a user supplied routine that initializes the variables `nsteps`, `timenow`, and `doexit`. (The same routine is also used in `PDAF_init_forecast`.)
* Status flag
* `status`:[[BR]] The integer status flag. It is zero, if the routine is exited without errors.
Note:
* The order of the routine names does not show the order in which these routines are executed. See the [#Executionorderofuser-suppliedroutines section on the order of the execution] at the bottom of this page.
=== `PDAF3_assim_offline_global` ===
For the offline mode of PDAF, the routine `PDAF3_assim_offline_global` is used to perform the analysis step.
The interface of the routine is identical with that of `PDAF3_assimilate_global`, except that the user-supplied routines `U_distribute_state`, `U_collect_state` and `U_next_observation` are missing.
The interface is:
{{{
SUBROUTINE PDAF3_assim_offline_global( &
init_dim_obs_pdafomi, obs_op_pdafomi, &
prepoststep_pdaf, status)
}}}
=== `PDAF3_put_state_global` ===
This routine exists for backward-compatibility. In implementations that were done before the release of PDAF V3.0, a 'put_state' routine was used for the `flexible` parallelization variant and for the offline mode.
When the 'flexible' implementation variant is chosen for the assimilation system, the routine. The routine `PDAF3_put_state_global` allows to port such implementations to the PDAF3 interface with minimal changes.
The interface of the routine is identical with that of `PDAF3_assimilate_global`, except that the user-supplied routines `U_distribute_state` and `U_next_observation` are missing.
The interface when using one of the local filters is the following:
{{{
SUBROUTINE PDAF3_put_state_global(collect_state_pdaf, &
init_dim_obs_pdafomi, obs_op_pdafomi, &
prepoststep_pdaf, status)
}}}
== User-supplied routines ==
Here, all user-supplied routines are described that are required in the call to `PDAF3_assimilate_global`, `PDAF3_assim_offline_global` or `PDAF3_put_state_global`. For some of the generic routines, we link to the page on [ModifyModelforEnsembleIntegration modifying the model code for the ensemble integration].
In the subroutine interfaces some variables appear with the suffix `_p` (short for 'process'). This suffix indicates that the variable is particular to a model sub-domain, if a domain decomposed model is used. In addition, there will be variables with suffix `_l` (indicating 'local').
Call-back routines that end on `_pdaf` are regular call-back routines from the core part of PDAF, while call-back routines that end on `_pdafomi` handle observations within PDAF-OMI.
=== `collect_state_pdaf` (collect_state_pdaf.F90) ===
This routine is independent of the filter algorithm used.
See the page on [ModifyModelforEnsembleIntegration#collect_state_pdafcollect_state_pdaf.F90 modifying the model code for the ensemble integration] for the description of this routine.
=== `distribute_state_pdaf` (distribute_state_pdaf.F90) ===
This routine is independent of the filter algorithm used.
See the page on [ModifyModelforEnsembleIntegration#distribute_state_pdafdistribute_state_pdaf.F90 modifying the model code for the ensemble integration] for the description of this routine.
=== `init_dim_obs_pdafomi` (callback_obs_pdafomi.F90) ===
This is a call-back routine initializing the observation information. The routine just calls a routine from the observation module for each observation type.
See the [wiki:OMI_Callback_obs_pdafomi_PDAF3 documentation on callback_obs_pdafomi.F90] for more information.
=== `obs_op_pdafomi` (callback_obs_pdafomi.F90) ===
This is a call-back routine applying the observation operator to the state vector. The routine calls a routine from the observation module for each observation type.
See the [wiki:OMI_Callback_obs_pdafomi_PDAF3 documentation on callback_obs_pdafomi.F90] for more information.
=== `prepoststep_pdaf` (prepoststep_ens_pdaf.F90) ===
The routine has already been described for modifying the model for the ensemble integration and for inserting the analysis step.
See the page on [ModifyModelforEnsembleIntegration#distribute_state_pdafdistribute_state_pdaf.F90 modifying the model code for the ensemble integration] for the description of this routine.
=== `next_observation_pdaf` (next_observation_pdaf.F90) ===
This routine is independent of the filter algorithm used.
See the page on [ModifyModelforEnsembleIntegration#distribute_state_pdafdistribute_state_pdaf.F90 modifying the model code for the ensemble integration] for the description of this routine.
== Execution order of user-supplied routines ==
The user-supplied routines are executed in the order listed below. The order can be important as some routines can perform preparatory work for routines executed later on during the analysis.
Before the analysis step is called the following is executed by `PDAF3_assimilate_global` and `PDAF3_put_state_global`:
1. [#collect_state_pdafcollect_state_pdaf.F90 collect_state_pdaf] (called once for each ensemble member)
1. [#prepoststep_pdafprepoststep_ens_pdaf.F90 prepoststep_pdaf] (Call to act on the forecast ensemble, called with negative value of the time step)
At the analysis time, the observations are initialized by the routines:
1. [#init_dim_obs_pdafomicallback_obs_pdafomi.F90 init_dim_obs_pdafomi]
1. [#obs_op_pdadfomicallback_obs_pdafomi.F90 obs_op_pdafomi] (Called `dim_ens` times; once for each ensemble member)
Now the analysis step is entered. Afterwards, it is executed:
1. [#prepoststep_pdafprepoststep_ens_pdaf.F90 prepoststep_pdaf] (Call to act on the analysis ensemble, called with (positive) value of the time step)
In case of the routine `PDAF3_assimilate_global`, the following routines are executed after the analysis step:
1. [#distribute_state_pdafdistribute_state_pdaf.F90 distribute_state_pdaf]
1. [#next_observation_pdafnext_observation_pdaf.F90 next_observation_pdaf]