Changes between Version 22 and Version 23 of ImplementAnalysisLocal


Ignore:
Timestamp:
Sep 19, 2024, 2:19:30 PM (3 weeks ago)
Author:
lnerger
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ImplementAnalysisLocal

    v22 v23  
    3737== Overview ==
    3838
    39 With Version 1.16 of PDAF we introduced PDAF-OMI (observation module infrastructure). With OMI we provide generic routines for the analysis step, which only distinguish global and local filters. This page describes the implementation of the analysis step for domain-local filters (LESTKF, LETKF, LNETF, LSEIK).
     39This page describes the recommended implementation of the analysis step of local filters with OMI using the PDAFlocal interface that was introduced with PDAF V2.3. The older approach calling PDAFomi_assimilate_local or PDAFomi_put_state_local is documented on the page on [wiki:ImplementAnalysisLocal Implementing the Analysis Step for the Local Filters with OMI without PDAFlocal (until V2.2.1 of PDAF)].
     40
     41PDAF-OMI provides generic routines for the analysis step, which only distinguish global and local filters. This page describes the implementation of the analysis step for domain-local filters (LESTKF, LETKF, LNETF, LSEIK).
    4042
    4143For the analysis step of the local filters 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 OMI structure. The names of the routines that are provided by the user are specified in the call to the routine `PDAFomi_assimilate_local` in the fully-parallel implementation (or `PDAFomi_put_state_local` for the 'flexible' implementation) that was discussed before. 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.
     
    4446
    4547
    46 == `PDAFomi_assimilate_local` ==
     48== `PDAFlocalomi_assimilate_local` ==
    4749
    4850The general aspects of the filter-specific routines `PDAF_assimilate_*` have been described on the page [ModifyModelforEnsembleIntegration Modification of the model code for the ensemble integration] and its sub-page on [InsertAnalysisStep inserting the analysis step].  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.
     
    5355The interface when using one of the local filters is the following:
    5456{{{
    55   SUBROUTINE PDAFomi_assimilate_local(U_collect_state, U_distribute_state, &
     57  SUBROUTINE PDAFlocalomi_assimilate_local(U_collect_state, U_distribute_state, &
    5658                                  U_init_dim_obs_pdafomi, U_obs_op_pdafomi, &
    5759                                  U_prepoststep, U_init_n_domains, U_init_dim_l, &
    58                                   U_init_dim_obs_l_pdafomi, U_g2l_state, U_l2g_state, &
     60                                  U_init_dim_obs_l_pdafomi, &
    5961                                  U_next_observation, status)
    6062}}}
     
    6769 * [#U_init_n_domainsinit_n_domains_pdaf.F90 U_init_n_domains]: The name of the routine that provides the number of local analysis domains
    6870 * [#U_init_dim_linit_dim_l_pdaf.F90 U_init_dim_l]: The name of the routine that provides the state dimension for a local analysis domain
    69  * [#U_init_dim_obs_l_pdafomicallback_obs_pdafomi.F90 U_init_dim_obs_l_pdafomi]: The name of the routine that initializes the size of the observation vector for a local analysis domain
    70  * [#U_g2l_stateg2l_state_pdaf.F90 U_g2l_state]: The name of the routine that initializes a local state vector from the global state vector
    71  * [#U_l2g_statel2g_state_pdaf.F90 U_l2g_state]: The name of the routine that initializes the corresponding part of the global state vector from the provided local state vector
     71 * [#U_init_dim_obs_l_pdafomicallback_obs_pdafomi.F90 U_init_dim_obs_l_pdafomi]: The name of the routine that initializes the size of the observation vector for a local analysis domain and the index arrays used to map between the global state vector and the local state vector.
    7272 * [#U_next_observationnext_observation.F90 U_next_observation]: The name of a user supplied routine that initializes the variables `nsteps`, `timenow`, and `doexit`. The same routine is also used in `PDAF_get_state`.
    7373 * `status`: The integer status flag. It is zero, if `PDAFomi_assimilate_local` is exited without errors.
     
    7575Note:
    7676 * 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.
    77 
    78 
    79 
    80 == `PDAFomi_put_state_local` ==
     77 * If your code shows a call to `PDAFomi_assimilate_local`, it uses the implementation variant without PDAFlocal. This is documented on the page on [wiki:ImplementAnalysisLocal Implementing the Analysis Step for the Local Filters with OMI without PDAFlocal (until V2.2.1 of PDAF)].
     78
     79
     80
     81== `PDAFlocalomi_put_state_local` ==
    8182
    8283When the 'flexible' implementation variant is chosen for the assimilation system, the routine `PDAFomi_put_state_local` has to be used instead of `PDAFomi_assimilate_local`. The general aspects of the filter specific routines `PDAF_put_state_*` have been described on the page [ModifyModelforEnsembleIntegration Modification of the model code for the ensemble integration]. The interface of the routine is identical with that of `PDAFomi_assimilate_local` with the exception the specification of the user-supplied routines `U_distribute_state` and `U_next_observation` are missing.
     
    8485The interface when using one of the local filters is the following:
    8586{{{
    86   SUBROUTINE PDAFomi_put_state_local(U_collect_state, &
     87  SUBROUTINE PDAFlocalomi_put_state_local(U_collect_state, &
    8788                                  U_init_dim_obs_pdafomi, U_obs_op_pdafomi, &
    8889                                  U_prepoststep, U_init_n_domains, U_init_dim_l, &
    89                                   U_init_dim_obs_l_pdafomi, U_g2l_state, U_l2g_state, &
     90                                  U_init_dim_obs_l_pdafomi, &
    9091                                  status)
    9192}}}
     93
     94 * If your code shows a call to `PDAFomi_put_state_local`, it uses the implementation variant without PDAFlocal. This is documented on the page on [wiki:ImplementAnalysisLocal Implementing the Analysis Step for the Local Filters with OMI without PDAFlocal (until V2.2.1 of PDAF)].
    9295
    9396== User-supplied routines ==
     
    167170The routine is called during the loop over the local analysis domains in the analysis step.
    168171For PDAF it has to provide in `dim_l` the dimension of the state vector for the local analysis domain with index `domain_p`.
     172
     173In addition, for PDAFlocal the routine has to provide the index array containing the indices of the elements of the local state vector in the global (or domain-decomposed) state vector to PDAFlocal by calling `PDAFlocal_set_indices'. (in the template files, this array is called `id_lstate_in_pstate`)
    169174
    170175Hints:
     
    178183   * In this case, `dim_l` will be the number of vertical grid points at this location times the number of model fields that exist in the vertical, plus possible variables at e.g. the surface.
    179184   * In this case only the horizontal coordinates are used in `coords_l`.
    180  * Further, we recommend to initialize an array containing the indices of the elements of the local state vector in the global (or domain-decomposed) state vector (`id_lstate_in_pstate` in the template files). This array is also shared through 'mod_assimilation'.
     185
     186The index array `id_lstate_in_pstate` is an integer array in form of a one-dimensional vector. One initializes this vector by determining the indices of the elements of the local state vector in the global, or domain decomposed, state vector. After initializing `id_lstate_in_pstate`, one has to provided it to PDAFlocal by calling `PDAFlocal_set_indices'. The interface interface is:
     187
     188{{{
     189SUBROUTINE PDAFlocal_set_indices(dim_l, id_lstate_in_pstate)
     190
     191  INTEGER, INTENT(in) :: dim_l                          ! Dimension of local state vector
     192  INTEGER, INTENT(in) :: id_lstate_in_pstate(dim_l)     ! Index array for mapping
     193}}}
     194
     195Hint for `id_lstate_in_pstate`:
     196 * The initialization of the index vector `map` is analogous to a loop that directly performs the initialization of a local state vector. However, here only the indices are stored.
     197 * See the [wiki:PDAFlocal_overview PDAFlocal overview page] for more information on the functionality of PDAFlocal.
    181198
    182199
     
    186203
    187204See the [wiki:OMI_Callback_obs_pdafomi documentation on callback_obs_pdafomi.F90] for more information.
    188 
    189 
    190 === `U_g2l_state` (g2l_state_pdaf.F90) ===
    191 
    192 The interface for this routine is:
    193 {{{
    194 SUBROUTINE g2l_state(step, domain_p, dim_p, state_p, dim_l, state_l)
    195 
    196   INTEGER, INTENT(in) :: step           ! Current time step
    197   INTEGER, INTENT(in) :: domain_p       ! Current local analysis domain
    198   INTEGER, INTENT(in) :: dim_p          ! State dimension for model sub-domain
    199   INTEGER, INTENT(in) :: dim_l          ! Local state dimension
    200   REAL, INTENT(in)    :: state_p(dim_p) ! State vector for model sub-domain
    201   REAL, INTENT(out)   :: state_l(dim_l) ! State vector on local analysis domain
    202 }}}
    203 
    204 The routine is called during the loop over the local analysis domains in the analysis step. It has to provide the local state vector `state_l` that corresponds to the local analysis domain with index `domain_p`. Provided to the routine is the state vector `state_p`. With a domain decomposed model, this is the state for the local model sub-domain.
    205 
    206 Hints:
    207  * In the simple case that a local analysis domain is a single vertical column of the model grid, the operation in this routine would be to take out of `state_p` the data for the vertical column indexed by `domain_p`.
    208  * Usually, one can use the index array `id_lstate_in_pstate`, which is initialized in `U_init_dim_l`. The array holds the indices of the local state vector elements in the global state vector.
    209 
    210 
    211 === `U_l2g_state` (l2g_state_pdaf.F90) ===
    212 
    213 The interface for this routine is:
    214 {{{
    215 SUBROUTINE l2g_state(step, domain_p, dim_l, state_l, dim_p, state_p)
    216 
    217   INTEGER, INTENT(in) :: step           ! Current time step
    218   INTEGER, INTENT(in) :: domain_p       ! Current local analysis domain
    219   INTEGER, INTENT(in) :: dim_p          ! State dimension for model sub-domain
    220   INTEGER, INTENT(in) :: dim_l          ! Local state dimension
    221   REAL, INTENT(in)    :: state_p(dim_p) ! State vector for model sub-domain
    222   REAL, INTENT(out)   :: state_l(dim_l) ! State vector on local analysis domain
    223 }}}
    224 
    225 The routine is called during the loop over the local analysis domains in the analysis step. It has to initialize the part of the global state vector `state_p` that corresponds to the local analysis domain with index `domain_p`. Provided to the routine is the state vector `state_l` for the local analysis domain.
    226 
    227 Hints:
    228  * In the simple case that a local analysis domain is a single vertical column of the model grid, the operation in this routine would be to write into `state_p` the data for the vertical column indexed by `domain_p`.
    229  * Usually, one can use the index array `id_lstate_in_pstate`, which is initialized in `U_init_dim_l`. The array holds the indices of the local state vector elements in the global state vector.
    230205
    231206
     
    253228 1. [#U_init_dim_linit_dim_l_pdaf.F90 U_init_dim_l]
    254229 1. [#U_init_dim_obs_l_pdafomiinit_dim_obs_l_pdaf.F90 U_init_dim_obs_l_pdafomi]
    255  1. [#U_g2l_stateg2l_state_pdaf.F90 U_g2l_state] (Called `dim_ens+1` times: Once for each ensemble member and once for the mean state estimate)
    256  1. [#U_l2g_statel2g_state_pdaf.F90 U_l2g_state] (Called `dim_ens+1` times: Once for each ensemble member and once for the mean state estimate)
    257230
    258231After the loop over all local analysis domains, it is executed: