Changes between Version 2 and Version 3 of ImplementAnalysisetkf
- Timestamp:
- May 17, 2011, 9:54:54 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ImplementAnalysisetkf
v2 v3 11 11 <li><a href="ImplementationofAnalysisStep">Implementation of the analysis step</a></li> 12 12 <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> 16 16 <li><a href="AddingMemoryandTimingInformation">Memory and timing information</a></li> 17 17 </ol> … … 23 23 == Overview == 24 24 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.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. 26 26 27 27 For 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. 28 28 29 The 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 29 31 == `PDAF_put_state_etkf` == 30 32 31 The general espects of the filter specific routines `PDAF_put_state_*` have been described on the page [ModifyModelforEnsembleIntegration Modification of the model co re 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.33 The 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. 32 34 33 35 The interface when using the ETKF method is the following: … … 49 51 == User-supplied routines == 50 52 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 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. 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!!! 53 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]. 54 55 To 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 57 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. 58 57 59 58 60 === `U_collect_state` (collect_state.F90) === 59 61 60 This routine is independent fromthe filter algorithm used.61 See [ModifyModelforEnsembleIntegration#U_collect_statecollect_state.F90 here] for the description of this routine.62 This routine is independent of the filter algorithm used. 63 See the page [ModifyModelforEnsembleIntegration#U_collect_statecollect_state.F90 modifying the model code for the ensemble integration] for the description of this routine. 62 64 63 65 … … 77 79 78 80 Some 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. 80 82 81 83 … … 88 90 SUBROUTINE obs_op(step, dim_p, dim_obs_p, state_p, m_state_p) 89 91 90 INTEGER, INTENT(in) :: step ! Curr rent time step92 INTEGER, INTENT(in) :: step ! Current time step 91 93 INTEGER, INTENT(in) :: dim_p ! PE-local dimension of state 92 94 INTEGER, INTENT(in) :: dim_obs_p ! Dimension of observed state … … 100 102 101 103 Hint: 102 * If the observation operator involves a global operation, e.g. some global integration, while using domain-decompos tion 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. 103 105 104 106 … … 122 124 123 125 124 === `U_prepoststep` (prepoststep_ seik.F90) ===126 === `U_prepoststep` (prepoststep_etkf.F90) === 125 127 126 See [ModifyModelforEnsembleIntegration#U_prepoststepprepoststep_seik.F90 here] for the description of this routine. 128 The 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 130 The interface for this routine is 131 {{{ 132 SUBROUTINE 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 149 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`). 150 151 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. 152 153 Hint: 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) 127 157 128 158 129 159 === `U_prodRinvA` (prodrinva.F90) === 130 160 131 This routine is used by all filter s whose algorithm usesthe 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)161 This routine is used by all filter algorithms that use the inverse of the observation error covariance matrix (SEEK, SEIK, and ETKF). 162 163 The interface for this routine is: 164 {{{ 165 SUBROUTINE prodRinvA(step, dim_obs_p, dim_ens, obs_p, A_p, C_p) 136 166 137 167 INTEGER, INTENT(in) :: step ! Current time step 138 168 INTEGER, INTENT(in) :: dim_obs_p ! PE-local dimension of obs. vector 139 INTEGER, INTENT(in) :: rank ! Rank of initial covariance matrix169 INTEGER, INTENT(in) :: dim_ens ! Ensemble size 140 170 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 routine142 REAL, INTENT(out) :: C_p(dim_obs_p, rank) ! Output matrix143 }}} 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 filterthis 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 175 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 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`. 146 176 147 177 For 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. 148 178 149 179 Hints: 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. 151 181 * 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. 152 183 153 184 154 185 === `U_init_obsvar` (init_obsvar.F90) === 155 186 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 imp ementation).187 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 implementation). 157 188 158 189 The interface for this routine is: … … 173 204 Hints: 174 205 * 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 ro tine 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. 176 207 177 208 178 209 == Execution order of user-supplied routines == 179 210 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 followingis executed:211 For 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 213 Before the analysis step is called, the following routine is executed: 183 214 1. [#U_collect_statecollect_state.F90 U_collect_state] 184 215 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)216 The 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) 187 218 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) 189 220 1. [#U_init_obsinit_obs.F90 U_init_obs] 190 221 1. [#U_obs_opobs_op.F90 U_obs_op] (`dim_ens` calls; one call for each ensemble member) 191 222 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)) 192 223 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