4.4. SIDL definition of the Midpoint component

  1. We will write a SIDL-based component that implements the port defined in previous steps and calls the integrate_mp method implemented in the legacy code described in Section 4.1, “The legacy Fortran integrator” to integrate a function, using function components that implement the function.FunctionPort port described in The integrator.IntegratorPort definition.

    Edit the file, student-src/components/sidl/integrators.sidl to define the class for the new integrator component, integrators.Midpoint:

    package integrators version 1.0 {
    
      // The following components implement all methods of the 
      // integrator.IntegratorPort and gov.cca.Component interfaces.
      // Since they use the SIDL 'implements-all' keyword, the 
      // methods do not need to (but optionally can) be listed explicitly.
    
      class Midpoint implements-all integrator.IntegratorPort, 
                                    gov.cca.Component
      {
      }
    
      class MonteCarlo implements-all integrator.IntegratorPort, 
                                      gov.cca.Component
                                      gov.cca.ComponentRelease
      {
        // integrator.IntegratorPort methods:
        double integrate(in double lowBound, in double upBound, 
                         in int count);
    
        // gov.cca.Component methods:
        void setServices(in gov.cca.Services services) 
                        throws gov.cca.CCAException;
    
        // gov.cca.ComponentRelease methods:
        void releaseServices(in gov.cca.Services services) 
                            throws gov.cca.CCAException;
      }
    }
    

    Note that the Midpoint class, unlike the MonteCarlo class does not implement the gov.cca.ComponentRelease interface, which is optional.

  2. Edit the file student-src/components/MakeIncl.components to add a new component description in the COMPONENTS variable, which contains the list of components in this directory. Each value consists of the fully-qualified name of the component (including packages), to which we append "-language", where language is one of c, c++, or f90. In this case, the name is integrators.Midpoint, and the language is f90, so you need to add integrators.Midpoint-f90. The updated value of COMPONENTS should look like something like this:

    COMPONENTS = functions.PiFunction-c++ \
            integrators.MonteCarlo-f90 randomgens.RandNumGenerator-c++ \
            drivers.F90Driver-f90 drivers.CXXDriver-c++  \
            integrators.Midpoint-f90
    

    Note the backslash (“\”) that has to be added in order to extend the entry to the next line.

  3. In the student-src/components directory, run make .repository. This will generate the XML representation of the integrator.Midpoint SIDL class and store it in the student-src/xml_repository directory.

  4. In the student-src/components directory, run make .integrators.Midpoint-f90. This will generate Fortran 90 server code for the integrators.Midpoint component class.