Changes between Version 61 and Version 62 of InitPdaf


Ignore:
Timestamp:
May 21, 2025, 10:05:43 PM (11 days ago)
Author:
lnerger
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • InitPdaf

    v61 v62  
    8989
    9090The routine `init_pdaf` in the example also initializes several variables that are not used to call `PDAF_init`. These variables control some functionality of the user-supplied routines for the data assimilation system and are shared with these routines through the Fortran module `mod_assimilation`. These variables are for example:
    91  * `delt_obs`: An integer specifying the number of time steps between two analysis steps
    92  * `rms_obs`: Assumed observation error (when PDAF-OMI is used the observation error is usually defined separately for each observation, see the [wiki:PDAF_OMI_Overview description of OMI])
    93  * `cradius`: Localization cut-off radius in grid points for the observation domain
     91 * `delt_obs`: An integer specifying the number of time steps between two analysis steps (used later in `next_observation_pdaf`)
     92 * `cradius`: Localization cut-off radius in grid points for the observation domain
    9493 * `sradius`: support radius, if observation errors are weighted (i.e. `locweight>0`)
    95  * `locweight`: Type of localizing weight
    96 It is useful to define variables like these at this central position. Of course, their definition has to be adapted to the particular model used. The example codes describe the options for `locweight`.
    97 
    98 The setting of `locweight` influences the weight function for the localization. If PDAF-OMI is used, the choices are standardized as follows
     94 * `locweight`: Type of localizing weight (see further below)
     95The latter three variables are localization parameters that are used later in the subroutines called by `init_dim_obs_l_pdafomi`.
     96
     97We recommend to define such configuration variables at this central position, so that all configuration is done at one place. Of course, their definition should be adapted to the particular model used.
     98
     99The setting of `locweight` influences the weight function for the localization. With the PDAF3 interface (and generally with PDAF-OMI), the choices are standardized as follows
    99100
    100101||= '''locweight''' =||= '''0''' =||= '''1''' =||= '''2''' =||= '''3''' =||= '''4''' =||
     
    107108
    108109
    109 == User-supplied routine `U_init_ens` (init_ens_pdaf.F90) ==
    110 
    111 The user-supplied routine the we named `U_init_ens` in the interface description above, is called by PDAF through the defined interface described below (Here, `U_` marks the variable to describe a user-supplied routine while in the actual code we use the name `init_ens_pdaf`). The routine is called by all MPI processes that compute the filter analysis step (i.e. those for which 'filterpe' is set to true. In the standard configuration of `init_parallel_pdaf` these are all processes of the first model task, i.e. task_id=1.) `init_ens_pdaf` is only called by `PDAF_init` if no error occurred before; thus the status flag is zero.
    112 
    113 The interface is the following:
    114 {{{
    115 SUBROUTINE U_init_ens(filtertype, dim_p, dim_ens, &
    116                            state_p, Uinv, ens_p, flag)
     110Apart from the generic variables for localization, we also specify variables that are specific for each observation type, for example in the tutorial code, we specify
     111 * `assim_A`: Flag whether to assimialtion observations of type A
     112 * `rms_obs_A`: Assumed observation error standard deviation of observation type A
     113
     114
     115== User-supplied routine `init_ens_pdaf` ==
     116
     117The user-supplied routine that we named `init_ens_pdaf` here, is the call-back routine that is called by PDAF through the defined interface described below. The routine is called by all MPI processes that compute the filter analysis step (i.e. those for which 'filterpe' is set to true. In the standard configuration of `init_parallel_pdaf` these are all processes of the first model task, i.e. task_id=1.) `init_ens_pdaf` is only called by `PDAF_init` if no error occurred before; thus the status flag is zero.
     118
     119The interface details can be looked up in the template and tutorial codes. It is the following:
     120{{{
     121SUBROUTINE init_ens_pdaf(filtertype, dim_p, dim_ens, &
     122                           state_p, Ainv, ens_p, flag)
    117123}}}
    118124with
    119125 * `filtertype`, `integer, intent(in)`:[[BR]]The type of filter algorithm as given in the call to `PDAF_init`
    120126 * `dim_p`, `integer, intent(in)`:[[BR]] The size of the state dimension for the calling process as specified in the call to `PDAF_init`
    121  * `dim_ens`, `integer, intent(in)`:[[BR]]The size of the ensemble (or the rank of the state covariance matrix for SEEK)
    122  * `state_p`, `real, dimension(dim_p), intent(inout)`:[[BR]]Array for the local model state of the calling process (Only relevant for mode-based filters)
    123  * `Uinv`, `real, dimension(dim_ens-1, dim_ens-1), intent(inout)`:[[BR]]A real array for the inverse of matrix '''U''' from the decomposition of the state error covariance matrix '''P''' = '''VUV^T^''' (Only relevant for the SEEK filter.)
    124  * `ens_p`, `real, dimension(dim_p, dim_ens), intent(inout)`:[[BR]]The ensemble array. It has to hold upon exit the ensemble of model states.
     127 * `dim_ens`, `integer, intent(in)`:[[BR]]The size of the ensemble
     128 * `state_p`, `real, dimension(dim_p), intent(inout)`:[[BR]]Array for the local model state of the calling process (can be used freely for ensemble-based methods)
     129 * `Ainv`, `real, dimension(dim_ens-1, dim_ens-1), intent(inout)`:[[BR]]A possible weight matrix (Not relevant for ensemble-based methods)
     130 * `ens_p`, `real, dimension(dim_p, dim_ens), intent(inout)`:[[BR]] The ensemble array, which has to be filled with the ensemble of model states.
    125131 * `flag`, `integer, intent(inout)`:[[BR]]Status flag for PDAF. It is 0 upon entry and can be set by in the user-supplied routine, depending on the success of the ensemble initialization.  Preferably, values above 102 should be used for failures to avoid conflicts with the error codes defined within PDAF_init.
    126132
    127133=== Defining the state vector ===
    128134
    129 The ensemble initialization routine is the first location at which the user has to fill a state vector (or array of state vectors). A state vector is the collection of all model fields that are handled in the analysis step of the assimilation procedure into a single vector. Usually one concatenates the different model fields as complete fields. Thus, the vector could contain a full 3-dimensional temperature field, followed by the salinity field (in case of an ocean model), and then followed by the 3 fields of the velocity components.
     135The ensemble initialization routine `init_ens_pdaf` is the first location at which the user has to fill a state vector (or array of state vectors). A state vector is the collection of all model fields that are handled in the analysis step of the assimilation procedure into a single vector. Usually one concatenates the different model fields as complete fields. Thus, the vector could contain a full 3-dimensional temperature field, followed by the salinity field (in case of an ocean model), and then followed by the 3 fields of the velocity components.
    130136
    131137The logical definition of the state vector will also be utilized in several other user-supplied routines. E.g. in routines that fill model fields from a state vector or in the routine providing the observation operator.
    132138
     139The actual setup of the state vector should be done in `init_pdaf`.  The tutorial example `tutorial/online_2D_serialmodel_2fields` demonstrates a possible setup of the state vector for 2 fields. Here, one defines the number of fields, the dimension of each included field as well as the offset of each field in the state vector.
     140
    133141
    134142=== Initialization for ensemble-based filters ===
    135143
    136 For the ensemble-based filters and the ensembel/hybrid 3D-Var methods only the array `ens_p` needs to be initialized by the ensemble of model states. If a parallel model with domain decomposition is used, the full ensemble for the local sub-domain has to be initialized.
    137 
    138 The arrays `state_p` and `Uinv` are allocated to their correct sizes because they are used during the assimilation cycles. They are not yet initialized and it is allowed to use these arrays in the initialization. An exception from this is EnKF for which `Uinv` is allocated only with size (1,1), because `Uinv` is not used for EnKF.
    139 
    140 
    141 === Initialization for mode-based filters ===
    142 
    143 The only mode-based filter supplied with PDAF is currenly the SEEK filter. For this filter, the initialization bases on the decomposition of the state error covariance matrix in the form '''P''' = '''VUV^T^'''. According to this decomposition, the array `ens_p` has to be initialized to hold the modes from matrix '''V''' and `Uinv` holds the inverse of matrix '''U'''. In addition `state_p` has to be initialized with the initial state estimate.  If a parallel model with domain decomposition is used, the part of all modes for the local sub-domain of the MPI process and the corresponding part of the state vector has to be initialized. '''Uinv''' will be identical for all MPI processes.
     144For the ensemble-based filters and the ensemble/hybrid 3D-Var methods, only the array `ens_p` needs to be initialized by the ensemble of model states. If a parallel model with domain decomposition is used, the full ensemble for the local sub-domain has to be initialized.
     145
     146The arrays `state_p` and `Ainv` are allocated to their correct sizes because they are used during the assimilation cycles. They are not yet initialized and it is allowed to use these arrays in the initialization. An exception from this is EnKF for which `Ainv` is allocated only with size (1,1), because `Ainv` is not used for EnKF.
     147
     148
     149== Setting additional options ==
     150
     151In PDAF V3.0 we added the possibility to set options for PDAF after the call to `PDAF_init`. For these there are the subroutines
     152{{{
     153   PDAF_set_iparam(id, value, status_pdaf)
     154}}}
     155to set interger parameters and
     156{{{
     157   PDAF_set_rparam(id, value, status_pdaf)
     158}}}
     159to set REAL (floating point) parameters. The arguments are
     160* `id`:[[BR]] The index value of a parameter
     161* `value`:[[BR]] The value of the parameter with index `id`
     162* `status_pdaf`:[[BR]] Status flag for PDAF. Both routines increment in the input value. The increment is 0 for no error (this allows to check `flag` once after all calls to `PDAF_init`, `PDAF_set_iparam`, and `PDAF_set_rparam`.)
     163
     164The tutorial code uses these routines for a few settings while the template code include an extended set of calls specific for different DA methods.
     165
     166An overview of available integer and real-valued options for each DA method can be found on the page [wiki:AvailableOptionsforInitPDAF Available options for the different DA methods]. The available options for a specific DA method can also be displayed by running the assimilation program for the selected DA method setting `subtype = -1`. (In the tutorial and template codes one can set `-subtype -1` on the command line).
     167
    144168
    145169== Testing the PDAF initialization ==
    146170
    147 The PDAF initialization can be tested by compiling the program and executing it. The Makefile of the model has to be extended to include the additional files.  The core part of PDAF can be compiled separately as a library and can then simply be linked to the model code. This is the strategy followed in the PDAF-package.
    148 
    149 '''Remark:''' For the compilation with a real MPI library, one has to ensure that MPI-module (`USE MPI`) of the MPI-library is USED for both the model and PDAF. (Thus in the include file for make in `make.arch`, one might have set `MPI_INC` to the directory holding the module.)
    150 
    151 At this stage it will not be meaningful to perform an actual model time stepping. However, one can test whether the initialization in PDAF_init is successful and whether the ensemble array is correctly initialized. For this one can also [wiki:PDAF_debugging activate the PDAF debugging output].
    152 
    153 Standard output from PDAF_init should look like the following:
    154 
    155 {{{
     171The PDAF initialization can be tested by compiling the assimilation program (one can out-comment the call to `PDAF3_assim_offline` if one likes to focus on the initialization) and executing it.
     172
     173Standard output from PDAF_init looks like the following:
     174{{{
     175PDAF    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     176PDAF    +++                       PDAF                         +++
     177PDAF    +++       Parallel Data Assimilation Framework         +++
     178PDAF    +++                                                    +++
     179PDAF    +++                 Version 3.0beta                    +++
     180PDAF    +++                                                    +++
     181PDAF    +++                   Please cite                      +++
     182PDAF    +++ L. Nerger and W. Hiller, Computers and Geosciences +++
     183PDAF    +++ 2013, 55, 110-118, doi:10.1016/j.cageo.2012.03.026 +++
     184PDAF    +++   when publishing work resulting from using PDAF   +++
     185PDAF    +++                                                    +++
     186PDAF    +++          PDAF itself can also be cited as          +++
     187PDAF    +++  L. Nerger. Parallel Data Assimilation Framework   +++
     188PDAF    +++  (PDAF). Zenodo. 2024. doi:10.5281/zenodo.7861812  +++
     189PDAF    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     190
     191
     192PDAF: Initialize filter
     193
    156194PDAF    ++++++++++++++++++++++++++++++++++++++++++++++++++++++
    157 PDAF    +++                      PDAF                      +++
    158 PDAF    +++      Parallel Data Assimilation Framework      +++
     195PDAF    +++ Error Subspace Transform Kalman Filter (ESTKF) +++
    159196PDAF    +++                                                +++
    160 PDAF    +++                 Version 2.1                    +++
    161 PDAF    +++                                                +++
    162 PDAF    +++                 Please cite                    +++
    163 PDAF    +++     L. Nerger and W. Hiller, Computers and     +++
    164 PDAF    +++         Geosciences, 2013, 55, 110-118,        +++
    165 PDAF    +++         doi:10.1016/j.cageo.2012.03.026        +++
    166 PDAF    +++ when publishing work resulting from using PDAF +++
     197PDAF    +++  Nerger et al., Mon. Wea. Rev. 140 (2012) 2335 +++
     198PDAF    +++           doi:10.1175/MWR-D-11-00102.1         +++
    167199PDAF    ++++++++++++++++++++++++++++++++++++++++++++++++++++++
    168 
    169 
    170 PDAF: Initialize filter
    171 
    172 PDAF    +++++++++++++++++++++++++++++++++++++++++++++++++++++++
    173 PDAF    +++  Local Error Subspace Transform Kalman Filter   +++
    174 PDAF    +++                    (LESTKF)                     +++
    175 PDAF    +++                                                 +++
    176 PDAF    +++ Domain-localized implementation of the ESTKF by +++
    177 PDAF    +++  Nerger et al., Mon. Wea. Rev. 140 (2012) 2335  +++
    178 PDAF    +++           doi:10.1175/MWR-D-11-00102.1          +++
    179 PDAF    +++++++++++++++++++++++++++++++++++++++++++++++++++++++
    180 
    181 PDAF    LESTKF configuration
    182 PDAF          filter sub-type = 0
    183 PDAF            --> Standard LESTKF
    184 PDAF            --> Transform ensemble with deterministic Omega
    185 PDAF            --> Use fixed forgetting factor: 1.00
    186 PDAF            --> ensemble size:  50
    187200
    188201PDAF: Initialize Parallelization
    189202PDAF     Parallelization - Filter on model PEs:
    190 PDAF                 Total number of PEs:      1
    191 PDAF      Number of parallel model tasks:      1
     203PDAF                 Total number of PEs:      6
     204PDAF      Number of parallel model tasks:      6
    192205PDAF                      PEs for Filter:      1
    193206PDAF     # PEs per ensemble task and local ensemble sizes:
    194 PDAF     Task     1
    195 PDAF     #PEs     1
    196 PDAF        N    50
    197 }}}
    198 
    199 The correctness of the ensemble initialization in `U_init_ens` should be checked by the user.
     207PDAF     Task     1     2     3     4     5     6
     208PDAF     #PEs     1     1     1     1     1     1
     209PDAF        N     1     1     1     1     1     1
     210
     211PDAF: Call ensemble initialization
     212
     213         Initialize state ensemble
     214         --- read ensemble from files
     215         --- Ensemble size:      6
     216
     217PDAF: Initialization completed
     218}}}
     219
     220The correctness of the ensemble initialization in `init_ens_pdaf` should be checked by the user.