Changes between Version 2 and Version 3 of ImplementAnalysisetkf


Ignore:
Timestamp:
May 17, 2011, 9:54:54 AM (14 years ago)
Author:
lnerger
Comment:

Adaption of SEIK text for ETKF.

Legend:

Unmodified
Added
Removed
Modified
  • ImplementAnalysisetkf

    v2 v3  
    1111<li><a href="ImplementationofAnalysisStep">Implementation of the analysis step</a></li>
    1212<ol>
    13 <li><a href="ImplementAnalysisseik">Implementation for SEIK</a></li></ol>
    14 <li><a href="ImplementAnalysislseik">Implementation for LSEIK</a></li></ol>
    15 <li>Implementation for ETKF</li>
     13<li><a href="ImplementAnalysisseik">Implementation for SEIK</a></li>
     14<li><a href="ImplementAnalysislseik">Implementation for LSEIK</a></li>
     15<li>Implementation for ETKF</li></ol>
    1616<li><a href="AddingMemoryandTimingInformation">Memory and timing information</a></li>
    1717</ol>
     
    2323== Overview ==
    2424
    25 For the analysis step of the ETKF 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_etkf` that was discussed before. With regard to the parallelization, all these routines are executed by the filter processes (`filterpe=1`) only.
     25For the analysis step of the ETKF, 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_etkf` that was discussed before. With regard to the parallelization, all these routines are executed by the filter processes (`filterpe=1`) only.
    2626
    2727For completeness we discuss here all user-supplied routines that are specified in the interface to PDAF_put_state_etkf. Thus, some of the user-supplied that are explained on the page explaining the modification of the model code for the ensemble integration are repeated here.
    2828
     29The SEIK filter and the ETKF (Ensemble Transform Kalman Filter) are very similar. For this reason, the interface to the user-supplied routines is almost identical. Depending on the implementation it can be possible to use identical routines for the SEIK filter and the ETKF. Differences are marked in the text below.
     30
    2931== `PDAF_put_state_etkf` ==
    3032
    31 The general espects of the filter specific routines `PDAF_put_state_*` have been described on the page [ModifyModelforEnsembleIntegration Modification of the model core for the ensemble integration]. Here, we list once more the full interface. Subsequently, the full set of user-supplied routines specified in the call to `PDAF_put_state_etkf` is explained.
     33The 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. Subsequently, the full set of user-supplied routines specified in the call to `PDAF_put_state_etkf` is explained.
    3234
    3335The interface when using the ETKF method is the following:
     
    4951== User-supplied routines ==
    5052
    51 Here all user-supplied routines are described that are required in the call to `PDAF_put_state_etkf`. For some of the generic routines, we link to the page on [ModifyModelforEnsembleIntegration modifying the model code for the ensemble integration].
    52 
    53 To indicate user-supplied routines we use the prefix `U_`. In the template directory `templates/` these routines are provided in files with the routines 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. In 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.
    54 
    55 
    56 GO ON HERE!!!
     53Here, all user-supplied routines are described that are required in the call to `PDAF_put_state_etkf`. For some of the generic routines, we link to the page on [ModifyModelforEnsembleIntegration modifying the model code for the ensemble integration].
     54
     55To 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.
     56
     57In 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.
     58
    5759
    5860=== `U_collect_state` (collect_state.F90) ===
    5961
    60 This routine is independent from the filter algorithm used.
    61 See [ModifyModelforEnsembleIntegration#U_collect_statecollect_state.F90 here] for the description of this routine.
     62This routine is independent of the filter algorithm used.
     63See the page [ModifyModelforEnsembleIntegration#U_collect_statecollect_state.F90 modifying the model code for the ensemble integration] for the description of this routine.
    6264
    6365
     
    7779
    7880Some hints:
    79  * It can be useful to not only determine the size of the observation vector is determined 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`.
     81 * 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.
    8082
    8183
     
    8890SUBROUTINE obs_op(step, dim_p, dim_obs_p, state_p, m_state_p)
    8991
    90   INTEGER, INTENT(in) :: step               ! Currrent time step
     92  INTEGER, INTENT(in) :: step               ! Current time step
    9193  INTEGER, INTENT(in) :: dim_p              ! PE-local dimension of state
    9294  INTEGER, INTENT(in) :: dim_obs_p          ! Dimension of observed state
     
    100102
    101103Hint:
    102  * If the observation operator involves a global operation, e.g. some global integration, while using domain-decompostion one has to gather the information from the other model domains using MPI communication.
     104 * 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.
    103105
    104106
     
    122124
    123125
    124 === `U_prepoststep` (prepoststep_seik.F90) ===
     126=== `U_prepoststep` (prepoststep_etkf.F90) ===
    125127 
    126 See [ModifyModelforEnsembleIntegration#U_prepoststepprepoststep_seik.F90 here] for the description of this routine.
     128The routine has 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 ETKF, the interface is generally identical. For completeness, we repeat the description here.
     129
     130The interface for this routine is
     131{{{
     132SUBROUTINE prepoststep(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, &
     133                       state_p, Uinv, ens_p, flag)
     134
     135  INTEGER, INTENT(in) :: step        ! Current time step
     136                         ! (When the routine is called before the analysis -step is provided.)
     137  INTEGER, INTENT(in) :: dim_p       ! PE-local state dimension
     138  INTEGER, INTENT(in) :: dim_ens     ! Size of state ensemble
     139  INTEGER, INTENT(in) :: dim_ens_p   ! PE-local size of ensemble
     140  INTEGER, INTENT(in) :: dim_obs_p   ! PE-local dimension of observation vector
     141  REAL, INTENT(inout) :: state_p(dim_p) ! PE-local forecast/analysis state
     142                                     ! The array 'state_p' is not generally not initialized in the case of SEIK/EnKF/ETKF.
     143                                     ! It can be used freely in this routine.
     144  REAL, INTENT(inout) :: Uinv(dim_ens, dim_ens) ! Inverse of matrix U
     145  REAL, INTENT(inout) :: ens_p(dim_p, dim_ens)  ! PE-local state ensemble
     146  INTEGER, INTENT(in) :: flag        ! PDAF status flag
     147}}}
     148
     149The 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`).
     150
     151The 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.
     152
     153Hint:
     154 * If a user considers to perform adjustments to the estimates (e.g. for balances), this routine is the right place for it.
     155 * The vector (`state_p`) is allocated but not initialized with the ensemble mean. It can be used freely during the execution of `U_prepoststep`, for example to compute the ensemble mean state.
     156 * The interface has a difference for ETKF and SEIK: For the ETKF, the array `Uinv` has size `dim_ens` x `dim_ens`. In contrast it has size `dim_ens-1` x `dim_ens-1` for the SEIK filter. (For most cases, this will be irrelevant, because most usually the ensemble array `ens_p` is used for computations, rather than `Uinv`. However, for the SEIK filter with fixed covariance matrix, `Uinv` is required to compute the estimate analysis error. The fixed covariance matrix mode is not available for the ETKF)
    127157
    128158
    129159=== `U_prodRinvA` (prodrinva.F90) ===
    130160
    131 This routine is used by all filters whose algorithm uses the inverse of the observation error covariance matrix (SEEK, SEIK, and ETKF).
    132 
    133 The interface for this routine is:
    134 {{{
    135 SUBROUTINE prodRinvA(step, dim_obs_p, rank, obs_p, A_p, C_p)
     161This routine is used by all filter algorithms that use the inverse of the observation error covariance matrix (SEEK, SEIK, and ETKF).
     162
     163The interface for this routine is:
     164{{{
     165SUBROUTINE prodRinvA(step, dim_obs_p, dim_ens, obs_p, A_p, C_p)
    136166
    137167  INTEGER, INTENT(in) :: step                ! Current time step
    138168  INTEGER, INTENT(in) :: dim_obs_p           ! PE-local dimension of obs. vector
    139   INTEGER, INTENT(in) :: rank                ! Rank of initial covariance matrix
     169  INTEGER, INTENT(in) :: dim_ens             ! Ensemble size
    140170  REAL, INTENT(in)    :: obs_p(dim_obs_p)    ! PE-local vector of observations
    141   REAL, INTENT(in)    :: A_p(dim_obs_p,rank) ! Input matrix from analysis routine
    142   REAL, INTENT(out)   :: C_p(dim_obs_p,rank) ! Output matrix
    143 }}}
    144 
    145 The 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 SEIK filter this matrix holds the observed part of the ensemble perturbations. The matrix is provided as `A_p`. The product has to be given as `C_p`.
     171  REAL, INTENT(in)    :: A_p(dim_obs_p, dim_ens) ! Input matrix from analysis routine
     172  REAL, INTENT(out)   :: C_p(dim_obs_p, dim_ens) ! Output matrix
     173}}}
     174
     175The 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 ETKF, this matrix holds the observed part of the ensemble perturbations. The matrix is provided as `A_p`. The product has to be given as `C_p`.
    146176
    147177For 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.
    148178
    149179Hints:
    150  * 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.
     180 * 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.
    151181 * 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.
     182 * The interface has a difference for SEIK and ETKF: For ETKF the third argument is the ensemble size (`dim_ens`), while for SEIK it is the rank of the covariance matrix (usually ensemble size minus one). In addition, the second dimension of `A_p` and `C_p` has size `dim_ens` for ETKF, while it is `rank` for the SEIK filter.
    152183
    153184
    154185=== `U_init_obsvar` (init_obsvar.F90) ===
    155186
    156 This routine is used by the global filter algorithms SEIK and  ETKF as well as the local filters LSEIK and LETKF. The routine is only called if the adaptive forgetting factor is used (`type_forget=1` in the example impementation).
     187This routine is used by the global filter algorithms SEIK and  ETKF as well as the local filters LSEIK and LETKF. The routine is only called if the adaptive forgetting factor is used (`type_forget=1` in the example implementation).
    157188
    158189The interface for this routine is:
     
    173204Hints:
    174205 * For a model with domain-decomposition one might use the mean variance for the model sub-domain of the calling process. Alternatively one can compute a mean variance for the full model domain using MPI communication (e.g. the function `MPI_allreduce`).
    175  * The observation vector `obs_p` is provided to the rotine for the case that the observation error variance is relative to the value of the observations.
     206 * The observation vector `obs_p` is provided to the routine for the case that the observation error variance is relative to the value of the observations.
    176207
    177208
    178209== Execution order of user-supplied routines ==
    179210
    180 For the SEIK filter, the user-supplied routines are essentially executed in the order they are listed in the interface to `PDAF_put_state_seik`. 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`.
    181 
    182 Before the analysis step is called the following is executed:
     211For the ETKF, the user-supplied routines are essentially executed in the order they are listed in the interface to `PDAF_put_state_etkf`. 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`.
     212
     213Before the analysis step is called, the following routine is executed:
    183214 1. [#U_collect_statecollect_state.F90 U_collect_state]
    184215
    185 When the ensemble integration of the forecast is completed the analysis step is executed. During the analysis step the following routines are executed in the given order:
    186  1. [#U_prepoststepprepoststep_seik.F90 U_prepoststep] (call to handle the forecast, called with negative value of the time step)
     216The 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:
     217 1. [#U_prepoststepprepoststep_etkf.F90 U_prepoststep] (call to handle the forecast, called with negative value of the time step)
    187218 1. [#U_init_dim_obsinit_dim_obs.F90 U_init_dim_obs]
    188  1. [#U_obs_opobs_op.F90 U_obs_op] (One call to operate on the ensemble mean state)
     219 1. [#U_obs_opobs_op.F90 U_obs_op] (A single call to operate on the ensemble mean state)
    189220 1. [#U_init_obsinit_obs.F90 U_init_obs]
    190221 1. [#U_obs_opobs_op.F90 U_obs_op] (`dim_ens` calls; one call for each ensemble member)
    191222 1. [#U_init_obsvarinit_obsvar.F90 U_init_obsvar] (Only executed, if the adaptive forgetting factor is used (`type_forget=1` in the example implemention))
    192223 1. [#U_prodRinvAprodrinva.F90 U_prodRinvA]
    193  1. [#U_prepoststepprepoststep_seik.F90 U_prepoststep] (call to handle the analysis, called with (positive) value of the time step)
    194 
     224 1. [#U_prepoststepprepoststep_etkf.F90 U_prepoststep] (call to handle the analysis, called with (positive) value of the time step)
     225