Tutorials

Under construction

New schemes: Overview

A post-processing scheme is represented by a class in the COMPS framework. Each component in COMPS has an abstract base class that specifies the functionality that a scheme of that class must implement in order to be used by COMPS.

As an example, consider the corrector component. Its header file is $COMPS/src/Correctors/Corrector.h.

 1 class Corrector : public Component {
 2    public:
 3       Corrector(const Options& iOptions, const Data& iData);
 4       void correct(const Parameters& iParameters, Ensemble& iEnsemble) const;
 5       void updateParameters(const std::vector<Ensemble>& iUnCorrected,
 6       const std::vector<Obs>& iObs,
 7       Parameters& iParameters) const;
 8       void getDefaultParameters(Parameters& iParameters) const;
 9       ...
10    protected:
11       virtual void correctCore(const Parameters& iParameters, Ensemble& iEnsemble) const = 0;
12       virtual void getDefaultParametersCore(Parameters& iParameters) const {};
13       //! Default: Don't update
14       //! Guarantee: Number of ensembles and obs are the same
15       virtual void updateParametersCore(const std::vector<Ensemble>& iUnCorrected,
16          const std::vector<Obs>& iObs,
17          Parameters& iParameters) const {};
18 }
COMPS passes the ensemble to the correct function. Corrector passes control to correctCore, which must be implemented by a corrector scheme.

There are two strategies for implementing new schemes:

  • Extending an existing scheme
  • Adding a new scheme

Adding a new scheme

To add an entirely new scheme, two new files must be created: $COMPS/src/<Component>s/<SchemeName>.h and $COMPS/src/<Component>s/<SchemeName>.cpp

Study the header file $COMPS/src/<Component>s/<Component>.h to see which functions you must write. Any function prefixed with virtual can be overwritten by your scheme. Any pure virtual function (i.e. ending in = 0;) must be implemented by your scheme. The non-pure virtual functions will execute some default behaviour if you do not override it.

In order for COMPS to know about your new scheme, you must run ./init in the root directory of COMPS. This generates some automated code that makes your scheme visible to COMPS.

Finally, to use the scheme you must add tthe scheme to a schemes namelist.

The next tutorial shows how a new correction scheme can be added.