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 Section 4.3, “The integrator.IntegratorPort Definition” (and defined in ).
$STUDENT_SRC/ports/sidl/function.sidl
Edit the file,
to define the class
for the new integrator component,
$STUDENT_SRC/components/sidl/integrators.sidlintegrators.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.
Edit the file
to add a new component description in the
$STUDENT_SRC/components/MakeIncl.componentsCOMPONENTS 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, cxx, 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-cxx \
integrators.MonteCarlo-f90 randomgens.RandNumGenerator-cxx \
drivers.F90Driver-f90 drivers.CXXDriver-cxx \
integrators.Midpoint-f90
Note the backslash (“\”) that has to
be added in order to extend the entry to the next line.
In the
directory, run
$STUDENT_SRC/componentsmake .repository.
This will generate the XML representation of the
integrator.Midpoint SIDL class and store it in the
directory.
$STUDENT_SRC/xml_repository
In the directory, run
$STUDENT_SRC/componentsmake .integrators.Midpoint-f90.
This will generate Fortran 90 server code for the
integrators.Midpoint component class.