Changes between Initial Version and Version 1 of ImplementAnalysisseek


Ignore:
Timestamp:
May 17, 2011, 4:14:38 PM (13 years ago)
Author:
lnerger
Comment:

Creating text for SEEK based on description for SEIK

Legend:

Unmodified
Added
Removed
Modified
  • ImplementAnalysisseek

    v1 v1  
     1= Implementation of the Analysis step for the SEEK filter =
     2
     3{{{
     4#!html
     5<div class="wiki-toc">
     6<h4>Implementation Guide</h4>
     7<ol><li><a href="ImplementationGuide">Main page</a></li>
     8<li><a href="AdaptParallelization">Adaptation of the parallelization</a></li>
     9<li><a href="InitPdaf">Initialization of PDAF</a></li>
     10<li><a href="ModifyModelforEnsembleIntegration">Modifications for ensemble integration</a></li>
     11<li><a href="ImplementationofAnalysisStep">Implementation of the analysis step</a></li>
     12<ol>
     13<li><a href="ImplementAnalysisseik">Implementation for SEIK</a></li>
     14<li><a href="ImplementAnalysislseik">Implementation for LSEIK</a></li>
     15<li><a href="ImplementAnalysisetkf">Implementation for ETKF</a></li>
     16<li><a href="ImplementAnalysisletkf">Implementation for LETKF</a></li>
     17<li>Implementation for SEEK</li>
     18</ol>
     19<li><a href="AddingMemoryandTimingInformation">Memory and timing information</a></li>
     20</ol>
     21</div>
     22}}}
     23
     24[[PageOutline(2-3,Contents of this page)]]
     25
     26== Overview ==
     27
     28For the analysis step of the SEEK filter different 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. This procedure should simplify the implementation. The names of the required routines are specified in the call to the routine `PDAF_put_state_seek`. With regard to the parallelization, all these routines are executed by the filter processes (`filterpe=1`) only.
     29
     30For completeness we discuss here all user-supplied routines that are specified in the interface to PDAF_put_state_seek. Thus, some of the user-supplied that are explained on the page explaining the modification of the model code for the ensemble integration for the SEIK filter are repeated here, but specified for the SEEK filter.
     31
     32The SEEK filter is very similar to the SEIK filter. In fact, the SEIK filter has been introduced as an interpolated (Pham et al., 1998) version of the SEEK filter. Due to the similarity of both filters, the interface to the user-supplied routines is almost identical. Several of the user-suppplied routines can be identical for SEEK and SEIK. Differences are marked in the text below. The implementation of the SEEK filter follows its original description by Pham et al. (1998) as reviewed by Nerger et al. (Tellus, 2005).
     33
     34There is no localized variant of the SEEK filter in PDAF. In Nerger et al. (Tellus, 2005), the SEIK filter performed much better than the SEEK filter. Due to this, we focused more on the SEIK filter after this comparison study.
     35 
     36
     37== `PDAF_put_state_seek` ==
     38
     39The general espects of the filter specific routines `PDAF_put_state_*` have been described on the page [ModifyModelforEnsembleIntegration Modification of the model code for the ensemble integration]. Here, we list once more the full interface specifically for the SEEK filter. Subsequently, the full set of user-supplied routines specified in the call to `PDAF_put_state_seek` is explained.
     40
     41The interface when using the SEEK filter is the following:
     42{{{
     43  SUBROUTINE PDAF_put_state_seek(U_collect_state, U_init_dim_obs, U_obs_op, &
     44                                 U_init_obs, U_prepoststep, U_prodRinvA, status)
     45}}}
     46with the following arguments:
     47 * [#U_collect_statecollect_state.F90 U_collect_state]: 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. This is basically the inverse operation to `U_distribute_state` used in `PDAF_get_state`
     48 * [#U_init_dim_obsinit_dim_obs.F90 U_init_dim_obs]: The name of the user-supplied routine that provides the size of observation vector
     49 * [#U_obs_opobs_op.F90 U_obs_op]: The name of the user-supplied routine that acts as the observation operator on some state vector
     50 * [#U_init_obsinit_obs.F90 U_init_obs]: The name of the user-supplied routine that initializes the vector of observations
     51 * [#U_prepoststepprepoststep_seek.F90 U_prepoststep]: The name of the pre/poststep routine as in `PDAF_get_state`
     52 * [#U_prodRinvAprodrinva.F90 U_prodRinvA]: The name of the user-supplied routine that computes the product of the inverse of the observation error covariance matrix with some matrix provided to the routine by PDAF. This operation occurs during the analysis step of the SEEK filter.
     53 * [#U_init_obsvarinit_obsvar.F90 U_init_obsvar]: The name of the user-supplied routine that provides a mean observation error variance to PDAF (This routine will only be executed, if an adaptive forgetting factor is used)
     54 * `status`: The integer status flag. It is zero, if `PDAF_put_state_seek` is exited without errors.
     55
     56
     57== User-supplied routines ==
     58
     59Here, all user-supplied routines are described that are required in the call to `PDAF_put_state_seek`. For some of the generic routines, we link to the page on [ModifyModelforEnsembleIntegration modifying the model code for the ensemble integration].
     60
     61To indicate user-supplied routines we use the prefix `U_`. In the template directory `templates/` these routines are provided in files with the routine's name without this prefix. In the example implementation in `testsuite/src/dummymodel_1D`, the routines exist without the prefix, but with the extension `_dummy_D.F90`. In the section titles below we provide the name of the template file in parentheses.
     62
     63In the subroutine interfaces some variables appear with the suffix `_p`. This suffix indicates that the variable is particular to a model sub-domain, if a domain decomposed model is used. Thus, the value(s) in the variable will be different for different model sub-domains.
     64
     65
     66=== `U_collect_state` (collect_state.F90) ===
     67
     68This routine is independent of the filter algorithm used.
     69See the page [ModifyModelforEnsembleIntegration#U_collect_statecollect_state.F90 modifying the model code for the ensemble integration] for the description of this routine.
     70
     71
     72=== `U_init_dim_obs` (init_dim_obs.F90) ===
     73
     74This routine is used by all global filter algorithms (SEEK, SEIK, EnKF, ETKF).
     75
     76The interface for this routine is:
     77{{{
     78SUBROUTINE init_dim_obs(step, dim_obs_p)
     79
     80  INTEGER, INTENT(in)  :: step       ! Current time step
     81  INTEGER, INTENT(out) :: dim_obs_p  ! Dimension of observation vector
     82}}}
     83
     84The routine is called at the beginning of each analysis step.  It has to initialize the size `dim_obs_p` of the observation vector according to the current time step. Without parallelization `dim_obs_p` will be the size for the full model domain. When a domain-decomposed model is used, `dim_obs_p` will be the size of the observation vector for the sub-domain of the calling process.
     85
     86Some hints:
     87 * It can be useful to not only determine the size of the observation vector at this point. One can also already gather information about the locations of the observations, which will be used later, e.g. to implement the observation operator. An array for the locations can be defined in a module like `mod_assimilation` of the example implementation.
     88
     89
     90=== `U_obs_op` (obs_op.F90) ===
     91
     92This routine is used by all global filter algorithms (SEEK, SEIK, EnKF, ETKF).
     93
     94The interface for this routine is:
     95{{{
     96SUBROUTINE obs_op(step, dim_p, dim_obs_p, state_p, m_state_p)
     97
     98  INTEGER, INTENT(in) :: step               ! Currrent time step
     99  INTEGER, INTENT(in) :: dim_p              ! PE-local dimension of state
     100  INTEGER, INTENT(in) :: dim_obs_p          ! Dimension of observed state
     101  REAL, INTENT(in)    :: state_p(dim_p)     ! PE-local model state
     102  REAL, INTENT(out) :: m_state_p(dim_obs_p) ! PE-local observed state
     103}}}
     104
     105The routine is called during the analysis step. It has to perform the operation of the observation operator acting on a state vector that is provided as `state_p`. The observed state has to be returned in `m_state_p`.
     106
     107For a model using domain decomposition, the operation is on the PE-local sub-domain of the model and has to provide the observed sub-state for the PE-local domain.
     108
     109Hint:
     110 * If the observation operator involves a global operation, e.g. some global integration, while using domain-decomposition one has to gather the information from the other model domains using MPI communication.
     111
     112
     113=== `U_init_obs` (init_obs.F90) ===
     114
     115This routine is used by all global filter algorithms (SEEK, SEIK, EnKF, ETKF).
     116
     117The interface for this routine is:
     118{{{
     119SUBROUTINE init_obs(step, dim_obs_p, observation_p)
     120
     121  INTEGER, INTENT(in) :: step             ! Current time step
     122  INTEGER, INTENT(in) :: dim_obs_p        ! PE-local dimension of obs. vector
     123  REAL, INTENT(out)   :: observation_p(dim_obs_p) ! PE-local observation vector
     124}}}
     125
     126The routine is called during the analysis step.
     127It has to provide the vector of observations in `observation_p` for the current time step.
     128
     129For a model using domain decomposition, the vector of observations that exist on the model sub-domain for the calling process has to be initialized.
     130
     131
     132=== `U_prepoststep` (prepoststep_seek.F90) ===
     133
     134The routine has already been described on the [ModifyModelforEnsembleIntegration#U_prepoststepprepoststep_seik.F90 page on modifying the model code for the ensemble integration] for the SEIK filter. For the SEEK filter there are some differences, because of the fact that the covariance matrix is computed from the modes and eigenvalue matrix rather than from an ensemble of model states.
     135
     136The interface of the routine is identical for all filters, but sizes can be different. In addition, the particular operations that are performed in the routine can be specific for each filter algorithm.
     137
     138The interface for this routine is for the SEEK filter
     139{{{
     140SUBROUTINE prepoststep(step, dim_p, rank, rank_p, dim_obs_p, &
     141                       state_p, Uinv, ens_p, flag)
     142
     143  INTEGER, INTENT(in) :: step        ! Current time step
     144                         ! (When the routine is called before the analysis -step is provided.)
     145  INTEGER, INTENT(in) :: dim_p       ! PE-local state dimension
     146  INTEGER, INTENT(in) :: dim_eof     ! Rank of covariance matrix (Number of EOF modes)
     147  INTEGER, INTENT(in) :: dim_eof_p   ! PE-local rank of covariance matrix/EOF modes
     148  INTEGER, INTENT(in) :: dim_obs_p   ! PE-local dimension of observation vector
     149  REAL, INTENT(inout) :: state_p(dim_p) ! PE-local forecast/analysis state
     150  REAL, INTENT(inout) :: Uinv(dim_eof, dim_eof)   ! Inverse of matrix U
     151  REAL, INTENT(inout) :: eofV_p(dim_p, dim_ens)    ! PE-local mode matrix V
     152  INTEGER, INTENT(in) :: flag        ! PDAF status flag
     153}}}
     154
     155The 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`).
     156
     157The routine provides for the user the full access to the EOF modes of the SEEK filter, as well as the eigenvalue matrix `Uinv` and the state estimate `state_p`. 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.
     158
     159Hint:
     160 * If a user considers to perform adjustments to the estimates (e.g. for balances), this routine is the right place for it.
     161 * 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`.
     162
     163
     164=== `U_prodRinvA` (prodrinva.F90) ===
     165
     166This routine is used by all filter algorithms that use the inverse of the observation error covariance matrix (SEEK, SEIK, and ETKF).
     167
     168The interface for this routine is:
     169{{{
     170SUBROUTINE prodRinvA(step, dim_obs_p, rank, obs_p, A_p, C_p)
     171
     172  INTEGER, INTENT(in) :: step                 ! Current time step
     173  INTEGER, INTENT(in) :: dim_obs_p            ! PE-local dimension of obs. vector
     174  INTEGER, INTENT(in) :: rank                 ! Rank of initial covariance matrix/Number of EOF modes
     175  REAL, INTENT(in)    :: obs_p(dim_obs_p)     ! PE-local vector of observations
     176  REAL, INTENT(in)    :: A_p(dim_obs_p, rank) ! Input matrix from analysis routine
     177  REAL, INTENT(out)   :: C_p(dim_obs_p, rank) ! Output matrix
     178}}}
     179
     180The routine is called during the analysis step. In the algorithms the product of the inverse of the observation error covariance matrix with some matrix has to be computed. For the SEEK filter this matrix holds the observed part of the EOF modes. The matrix is provided as `A_p`. The product has to be given as `C_p`.
     181
     182For a model with domain decomposition, `A_p` contains the part of the matrix that resides on the model sub-domain of the calling process. The product has to be computed for this sub-domain, too.
     183
     184Hints:
     185 * The routine does not require that the product is implemented as a real matrix-matrix product. Rather, the product can be implemented in its most efficient form. For example, if the observation error covariance matrix is diagonal, only the multiplication of the diagonal with matrix `A_p` has to be implemented.
     186 * The observation vector `obs_p` is provided through the interface for cases where the observation error variance is relative to the actual value of the observations.
     187
     188
     189== Execution order of user-supplied routines ==
     190
     191For the SEEK filter, the user-supplied routines are essentially executed in the order they are listed in the interface to `PDAF_put_state_seek`. The order can be important as some routines can perform preparatory work for later routines. For example, `U_init_dim_obs` can prepare an index array that provides the information for executing the observation operator in `PDAF_obs_op`.
     192
     193Before the analysis step is called the following routine is executed:
     194 1. [#U_collect_statecollect_state.F90 U_collect_state]
     195
     196The analysis step is executed when the ensemble integration of the forecast is completed. During the analysis step the following routines are executed in the given order:
     197 1. [#U_prepoststepprepoststep_seek.F90 U_prepoststep] (Call to act on the forecast ensemble, called with negative value of the time step)
     198 1. [#U_init_dim_obsinit_dim_obs.F90 U_init_dim_obs]
     199 1. [#U_obs_opobs_op.F90 U_obs_op] (A single call to operate on the ensemble mean state)
     200 1. [#U_init_obsinit_obs.F90 U_init_obs]
     201 1. [#U_obs_opobs_op.F90 U_obs_op] (`dim_eof` calls: one call for each ensemble member)
     202 1. [#U_prodRinvAprodrinva.F90 U_prodRinvA]
     203 1. [#U_prepoststepprepoststep_seek.F90 U_prepoststep] (Call to act on the analysis ensemble, called with (positive) value of the time step)