Changes between Version 20 and Version 21 of ImplementAnalysislestkf


Ignore:
Timestamp:
Jun 4, 2025, 9:47:25 AM (2 days ago)
Author:
lnerger
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ImplementAnalysislestkf

    v20 v21  
    4141== Overview ==
    4242
    43 With Version 1.8 of PDAF, the LESTKF (Local Error Subspace Transform Kalman Filter) algorithm has been introduced. The user-supplied routines required for the LESTKF are identical to those required for the LSEIK filter.
     43The LESTKF (Local Error Subspace Transform Kalman Filter, Nerger et al., 2012) is a particularly efficient ensemble-based Kalman filter method. It has been introduced with Version 1.8 of PDAF. The user-supplied routines required for the LESTKF are identical to those required for the LSEIK filter, and nearly identical to those of the LETKF.
    4444
    4545For the analysis step of the LESTKF, several operations related to the observations are needed. These operations are requested by PDAF by calling user-supplied routines. Intentionally, the operations are split into separate routines in order to keep the operations rather elementary as this procedure should simplify the implementation. The names of the required routines are specified in the call to the routine `PDAF_assimilate_lestkf` in the fully-parallel implementation (or `PDAF_put_state_lestkf` for the 'flexible' implementation) described below. With regard to the parallelization, all these routines (except `U_collect_state`, `U_distribute_state`, and `U_next_observation`) are executed by the filter processes (`filterpe=.true.`) only.
     
    5252== `PDAF_assimilate_lestkf` ==
    5353
    54 The general aspects of the filter-specific routines `PDAF_assimilate_*` have been described on the page [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3 Modification of the model code for the ensemble integration].  The routine is used in the fully-parallel implementation variant of the data assimilation system. When the 'flexible' implementation variant is used, the routines `PDAF_put_state_*' is used as described further below.
    55 The interface for the routine `PDAF_assimilate_lestkf` contains several routine names for routines that operate on the local analysis domains (marked by `_l` at the end of the routine name). In addition, there are names for routines that consider all available observations required to perform local analyses with LESTKF within some sub-domain of a domain-decomposed model (marked by `_f` at the end of the routine name). In case of a serial execution of the assimilation program, these will be all globally available observations. However, if the program is executed with parallelization, this might be a smaller set of observations.
    56 
    57 To explain the  difference, it is assumed, for simplicity, that a local analysis domain consists of a single vertical column of the model grid. In addition, we assume that the domain decomposition splits the global model domain by vertical boundaries as is typical for ocean models and that the observations are spatially distributed observations of model fields that are part of the state vector.  Under these assumptions, the situation is the following: When a model uses domain decomposition, the LESTKF is executed such that for each model sub-domain a loop over all local analysis domains (e.g. vertical columns) that belong to the model sub-domain is performed. As each model sub-domain is treated by a different process, all loops are executed parallel to each other.
    58 
    59 For the update of each single vertical column, observations from some larger domain surrounding the vertical column are required. If the influence radius for the observations is sufficiently small there will be vertical columns for which the relevant observations reside completely inside the model sub-domain of the process. However, if a vertical column is considered that is located close to the boundary of the model sub-domain, there will be some observations that don't belong spatially to the local model sub-domain, but to a neighboring model sub-domain. Nonetheless, these observations are required on the local model sub-domain. A simple way to handle this situation is to initialize for each process all globally available observations, together with their coordinates. While this method is simple, it can also become inefficient if the assimilation program is executed using a large number of processes. As for an initial implementation it is usually not the concern to obtain the highest parallel efficiency, the description below assumes that 'full' refers to the global model domain.
    60 
    61 The interface when using the LESTKF algorithm is the following:
    62 {{{
    63   SUBROUTINE PDAF_assimilate_lestkf(U_collect_state, U_distribute_state, U_init_dim_obs_f, U_obs_op_f, &
    64                                   U_init_obs_f, U_init_obs_l, U_prepoststep, U_prodRinvA_l,  &
    65                                   U_init_n_domains,U_init_dim_l, U_init_dim_obs_l, &
     54This routine is used both in the ''fully-parallel'' and the ''flexible'' implementation variants of the data assimilation system. (See the page [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3 Modification of the model code for the ensemble integration] for these variants)
     55
     56The interface for the routine `PDAF_assimilate_lestkf` contains several routine names for routines that operate on the local analysis domains (marked by `_l` at the end of the routine name). In addition, there are names for routines that consider all available observations required to perform local analyses with LESTKF within some sub-domain of a domain-decomposed model (we refer to these as 'full' observations, marked by `_f` at the end of the routine name). In case of a serial execution of the assimilation program, these will be all globally available observations. However, if the program is executed with parallelization, one might choose a smaller set of observations. We will explain this is some detail below.
     57
     58Here, we list the full interface of the routine. Subsequently, the user-supplied routines specified in the call are explained.
     59
     60The interface is:
     61{{{
     62  SUBROUTINE PDAF_assimilate_lestkf(U_collect_state, U_distribute_state, &
     63                                  U_init_dim_obs_f, U_obs_op_f, U_init_obs_f, &
     64                                  U_init_obs_l, U_prepoststep, U_prodRinvA_l,  &
     65                                  U_init_n_domains, U_init_dim_l, U_init_dim_obs_l, &
    6666                                  U_g2l_state, U_l2g_state, U_g2l_obs, &
    6767                                  U_init_obsvar, U_init_obsvar_l, U_next_observation, status)
     
    9191
    9292
    93 
    94 == `PDAF_put_state_lestkf` ==
    95 
    96 When the 'flexible' implementation variant is chosen for the assimilation system, the routine `PDAF_put_state_lestkf` has to be used instead of `PDAF_assimilate_lestkf`. The general aspects of the filter specific routines `PDAF_put_state_*` have been described on the page [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3 Modification of the model code for the ensemble integration]. The interface of the routine is identical with that of `PDAF_assimilate_lestkf` with the exception the specification of the user-supplied routines `U_distribute_state` and `U_next_observation` are missing.
    97 
    98 The interface when using the LESTKF algorithm is the following:
    99 {{{
    100   SUBROUTINE PDAF_put_state_lestkf(U_collect_state, U_init_dim_obs_f, U_obs_op_f, U_init_obs_f, &
    101                                   U_init_obs_l, U_prepoststep, U_prodRinvA_l, U_init_n_domains, &
    102                                   U_init_dim_l, U_init_dim_obs_l, &
     93== `PDAF_assim_offline_lestkf ` ==
     94
     95This routine is used to perform the analysis step for the offline mode of PDAF.
     96The interface of the routine is identical with that of the 'assimilate'-routine, except that the user-supplied routines `U_distribute_state`, `U_collect_state` and `U_next_observation` are missing.
     97
     98The interface is:
     99{{{
     100  SUBROUTINE PDAF_assim_offline_lestkf(&
     101                                  U_init_dim_obs_f, U_obs_op_f, U_init_obs_f, &
     102                                  U_init_obs_l, U_prepoststep, U_prodRinvA_l,  &
     103                                  U_init_n_domains, U_init_dim_l, U_init_dim_obs_l, &
    103104                                  U_g2l_state, U_l2g_state, U_g2l_obs, &
    104105                                  U_init_obsvar, U_init_obsvar_l, status)
    105106}}}
    106107
     108
     109
     110== `PDAF_put_state_lestkf` ==
     111
     112This routine exists for backward-compatibility. In implementations that were done for PDAF V2.3.1 and before, a 'put_state' routine was used for the `flexible` parallelization variant and for the offline mode.
     113When the 'flexible' implementation variant is chosen for the assimilation system, the routine. This routine allows to continue using the previous implementation structure.
     114The interface of the routine is identical with that of the 'assimilate'-routine, except that the user-supplied routines `U_distribute_state` and `U_next_observation` are missing.
     115
     116The interface is:
     117{{{
     118  SUBROUTINE PDAF_put_state_lestkf(U_collect_state, &
     119                                  U_init_dim_obs_f, U_obs_op_f, U_init_obs_f, &
     120                                  U_init_obs_l, U_prepoststep, U_prodRinvA_l,  &
     121                                  U_init_n_domains, U_init_dim_l, U_init_dim_obs_l, &
     122                                  U_g2l_state, U_l2g_state, U_g2l_obs, &
     123                                  U_init_obsvar, U_init_obsvar_l, status)
     124}}}
     125
     126== Explanation of 'full observations' ==
     127
     128Above we mention the concept of 'full' observations. We distinguish them from the globally available observations for efficiency.
     129
     130Note: For an initial implementation, one might not needd to worry about high efficiency, so that 'full' can refer to all available observations.
     131
     132To explain why 'full' observations can be different from globally available observations, we assume, for simplicity, that  we have a 2-dimensional domain and that a local analysis domain consists of a single grid point of the model grid. In addition, we assume that the domain decomposition splits the global model domain in compact sub-domains and that the observations are spatially distributed observations of model fields that are part of the state vector. 
     133
     134The LESTKF performs a loop over all local analysis domains, i.e. grid points.  When a model uses domain decomposition, the loop is over all grid points that belong to a process sub-domain. As each model sub-domain is treated by a different process, all loops are executed parallel to each other.
     135
     136For the update of each local analysis domain (grid points), observations within the localization radius around its location are required. If the influence radius for the observations is sufficiently small, there will be grid points a for which the relevant observations reside completely inside the model sub-domain of the process. However, if a grid point is located close to the boundary of the model sub-domain, there will be some observations that reside on a neighboring process sub-domain, but are within the localization radius. One needs to assimilate these observations as otherwise, there could be unrealistic steps in the analysis field. However, there will also be observations that reside far away from the process sub-domain and will never influence the analysis result in this domain.
     137
     138A simple way to handle this situation is to initialize for each process all globally available observations, together with their coordinates. The observation operator would be applied on each sub-domain and then the observed ensemble would be collect using parallel communication with MPI. While this method is simple, it can also become inefficient if the assimilation program is executed using a large number of processes. In particular, all observation would need to be checked even if they are far away from the process sub-domain.
     139
     140More efficient is hence to select as 'full' observations only those observations that can have an effect on the local analyses of a process sub-domain. These are the observations that reside within the sub-domain, plus observations in neighboring sub-domains that reside within the localization radius. Setting up 'full' observations in this way leads to a smaller number of observations whose distance need to be checked for each local analysis domain. Howeever, one would need to find an implementation that provides the 'full' observations.
     141
     142|| Note: The handling of 'full' observations is one of the aspects that motivated the development of PDAF-OMI and the relaed avanced interface (now the PDAF3 interface). Here, PDAF-OMI does take case of the 'full' observations. See the [wiki:ImplementationofAnalysisStep_PDAF3 Implementation Guide for the Analysis Step for the advanced interface using PDAF-OMI]. ||
     143
     144
    107145== User-supplied routines ==
    108146
    109 Here, all user-supplied routines are described that are required in the call to `PDAF_assimilate_lestkf` or `PDAF_put_state_lestkf`. For some of the generic routines, we link to the page on [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3 modifying the model code for the ensemble integration].
     147Here, all user-supplied routines are described that are required in the calls to the analysis routines. For some of the generic routines, we link to the page on [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3 modifying the model code for the ensemble integration].
    110148
    111149To 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.
     
    115153=== `U_collect_state` (collect_state_pdaf.F90) ===
    116154
    117 This routine is independent from the filter algorithm used.
    118 See the mape on [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3#U_collect_statecollect_state_pdaf.F90 inserting the analysis step] for the description of this routine.
     155This routine is independent of the filter algorithm used.
     156See the page on [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3#collect_state_pdafcollect_state_pdaf.F90 modifying the model code for the ensemble integration] for the description of this routine.
     157
    119158
    120159=== `U_distribute_state` (distribute_state_pdaf.F90) ===
    121160
    122161This routine is independent of the filter algorithm used.
    123 See the page on [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3#U_distribute_statedistribute_state_pdaf.F90 inserting the analysis step] for the description of this routine.
     162See the page on [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3#distribute_state_pdafdistribute_state_pdaf.F90 modifying the model code for the ensemble integration] for the description of this routine.
     163
    124164
    125165
     
    207247=== `U_prepoststep` (prepoststep_ens_pdaf.F90) ===
    208248
    209 This routine can be identical to that used for the global ESTKF algorithm, which has already been described on the [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3#U_prepoststepprepoststep_ens.F90 page on modifying the model code for the ensemble integration]. For completeness, the description is repeated:
    210 
    211 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.
    212 
    213 The interface for this routine is
    214 {{{
    215 SUBROUTINE prepoststep(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, &
    216                        state_p, Uinv, ens_p, flag)
    217 
    218   INTEGER, INTENT(in) :: step        ! Current time step
    219                          ! (When the routine is called before the analysis -step is provided.)
    220   INTEGER, INTENT(in) :: dim_p       ! PE-local state dimension
    221   INTEGER, INTENT(in) :: dim_ens     ! Size of state ensemble
    222   INTEGER, INTENT(in) :: dim_ens_p   ! PE-local size of ensemble
    223   INTEGER, INTENT(in) :: dim_obs_p   ! PE-local dimension of observation vector
    224   REAL, INTENT(inout) :: state_p(dim_p) ! PE-local forecast/analysis state
    225                                      ! The array 'state_p' is not generally not initialized in the case of SEIK/EnKF/ETKF/ESTKF.
    226                                      ! It can be used freely in this routine.
    227   REAL, INTENT(inout) :: Uinv(dim_ens-1, dim_ens-1) ! Inverse of matrix U
    228   REAL, INTENT(inout) :: ens_p(dim_p, dim_ens)      ! PE-local state ensemble
    229   INTEGER, INTENT(in) :: flag        ! PDAF status flag
    230 }}}
    231 
    232 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`).
    233 
    234 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.
    235 
    236 Hint:
    237  * If a user considers to perform adjustments to the estimates (e.g. for balances), this routine is the right place for it.
    238  * 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`.
    239  * The interface has a difference for LETKF and LESTKF: For the LETKF, the array `Uinv` has size `dim_ens` x `dim_ens`. In contrast it has size `dim_ens-1` x `dim_ens-1` for the LESTKF.
    240  * 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])
    241 
     249The routine has already been described for modifying the model for the ensemble integration and for inserting the analysis step.
     250
     251See the page on [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3#distribute_state_pdafdistribute_state_pdaf.F90 modifying the model code for the ensemble integration] for the description of this routine.
    242252
    243253
     
    447457
    448458This routine is independent of the filter algorithm used.
    449 See the page on [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3#U_next_observationnext_observation_pdaf.F90 inserting the analysis step] for the description of this routine.
     459See the page on [wiki:OnlineModifyModelforEnsembleIntegration_PDAF3#next_observation_pdafnext_observation_pdaf.F90 modifying the model code for the ensemble integration] for the description of this routine.
    450460
    451461