77 | | === `U_next_observation` (next_observation.F90) === |
78 | | |
79 | | The interface for this routine is |
80 | | {{{ |
81 | | SUBROUTINE U_next_obs(stepnow, nsteps, doexit, timenow) |
82 | | |
83 | | INTEGER, INTENT(in) :: stepnow ! Number of the current time step |
84 | | INTEGER, INTENT(out) :: nsteps ! Number of time steps until next obs |
85 | | INTEGER, INTENT(out) :: doexit ! Whether to exit forecasting (1 for exit) |
86 | | REAL, INTENT(out) :: timenow ! Current model (physical) time |
87 | | }}} |
88 | | |
89 | | The routine is called once at the beginning of each forecast phase. It is executed by all processes that participate in the model integrations. |
90 | | |
91 | | Based on the information of the current time step, the routine has to define the number of time steps `nsteps` for the next forecast phase. In addition, the flag `doexit` has to be initialized to provide the information if the external ensemble loop can be exited. `timenow` is the current model time. This variable should also be initialized. It is particularly important, if an ensemble task integrates more than one model state. In this case `timenow` can be used to correctly jump back in time. |
92 | | |
93 | | Some hints: |
94 | | * If the time interval between successive observations is known, `nsteps` can be simply initialized by dividing the time interval by the size of the time step |
95 | | * `doexit` should be 0 to continue the assimilation process. In most cases `doexit` is set to 1, when `PDAF_get_state` is called after the last analysis for which observations are available. |
96 | | * At the first call to `U_next_obs` the variable `timenow` should be initialized with the current model time. At the next call a forecast phase has been completed. Thus, the new value of `timenow` follows from the timer interval for the previous forecast phase. |
97 | | |
98 | | === `U_distribute_state` (distribute_state.F90) === |
99 | | |
100 | | The interface for this routine is |
101 | | {{{ |
102 | | SUBROUTINE distribute_state(dim_p, state_p) |
103 | | |
104 | | INTEGER, INTENT(in) :: dim_p ! State dimension for PE-local model sub-domain |
105 | | REAL, INTENT(inout) :: state_p(dim_p) ! State vector for PE-local model sub-domain |
106 | | }}} |
107 | | |
108 | | This routine is called during the forecast phase as many times as there are states to be integrated by a model task. Again, the routine is executed by all processes that belong to model tasks. |
109 | | |
110 | | When the routine is called a state vector `state_p` and its size `dim_p` are provided. As the user has defined how the model fields are stored in the state vector, one can initialize the model fields from this information. If the model is not parallelized, `state_p` will contain a full state vector. If the model is parallelized using domain decomposition, `state_p` will contain the part of the state vector that corresponds to the model sub-domain for the calling process. |
111 | | |
112 | | Some hints: |
113 | | * If the state vector does not include all model fields, it can be useful to keep a separate array to store those additional fields. This array has to be kept separate from PDAF, but can be defined using a module like `mod_assimilation`. |
114 | | |
119 | | The interface for this routine is |
120 | | {{{ |
121 | | SUBROUTINE prepoststep(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, & |
122 | | state_p, Uinv, ens_p, flag) |
123 | | |
124 | | INTEGER, INTENT(in) :: step ! Current time step |
125 | | ! (When the routine is called before the analysis -step is provided.) |
126 | | INTEGER, INTENT(in) :: dim_p ! PE-local state dimension |
127 | | INTEGER, INTENT(in) :: dim_ens ! Size of state ensemble |
128 | | INTEGER, INTENT(in) :: dim_ens_p ! PE-local size of ensemble |
129 | | INTEGER, INTENT(in) :: dim_obs_p ! PE-local dimension of observation vector |
130 | | REAL, INTENT(inout) :: state_p(dim_p) ! PE-local forecast/analysis state |
131 | | ! The array 'state_p' is not generally not initialized in the case of SEIK. |
132 | | ! It can be used freely here. |
133 | | REAL, INTENT(inout) :: Uinv(dim_ens-1, dim_ens-1) ! Inverse of matrix U |
134 | | REAL, INTENT(inout) :: ens_p(dim_p, dim_ens) ! PE-local state ensemble |
135 | | INTEGER, INTENT(in) :: flag ! PDAF status flag |
136 | | }}} |
137 | | |
138 | | 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`). |
139 | | |
140 | | 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. |
141 | | |
142 | | Hint: |
143 | | * If a user considers to perform adjustments to the estimates (e.g. for balances), this routine is the right place for it. |
144 | | |
145 | | |
146 | | === `U_collect_state` (collect_state.F90) === |
147 | | |
148 | | The interface for this routine is |
149 | | {{{ |
150 | | SUBROUTINE collect_state(dim_p, state_p) |
151 | | |
152 | | INTEGER, INTENT(in) :: dim_p ! State dimension for PE-local model sub-domain |
153 | | REAL, INTENT(inout) :: state_p(dim_p) ! State vector for PE-local model sub-domain |
154 | | }}} |
155 | | |
156 | | This routine is called during the forecast phase as many times as there are states to be integrated by a model task. It is called at the end of the integration of a member state of the ensemble. The routine is executed by all processes that belong to model tasks. |
157 | | |
158 | | When the routine is called, a state vector `state_p` and its size `dim_p` are provided. The operation to be performed in this routine is inverse to that of the routine `U_distribute_state`. That is, the state vector `state_p` has to be initialized from the model fields. If the model is not parallelized, `state_p` will contain a full state vector. If the model is parallelized using domain decomposition, `state_p` will contain the part of the state vector that corresponds to the model sub-domain for the calling process. |
159 | | |
160 | | Some hints: |
161 | | * If the state vector does not include all model fields, it can be useful to keep a separate array to store those additional fields. This array has to be kept separate from PDAF, but can be defined using a module like `mod_assimilation`. |