Chapter 3. Using Bocca: An Application Generator for CCA

$Revision: 1.51 $

$Date: 2007/11/10 16:52:48 $

Table of Contents

3.1. Creating a Bocca Project
3.2. Creating Ports and Components
3.3. Inserting Implementations into Bocca-Generated Components
3.3.1. Adding Methods to Ports
3.4. Language-Specific Implementations of the Function, Integrator, and Driver Components
3.4.1. C++ Implementation
3.4.2. Fortran9X Implementation
3.4.3. C Implementation

While the CCA specification allows you to create components "by hand", it is much quicker to use an application generator that provides templated code for components and a build system. Naturally bocca cannot create your implementation for you, but all of the glue code for multilanguage interoperability and component interfaces in a CCA application is created and maintained with a few commands. The advantage of this approach is that a lot of build and component defaults have been chosen for you. The downside is that, while some customization is possible, the project directory and file structures are largely predetermined.

3.1.  Creating a Bocca Project

If your CCA environment is configured properly (Appendix B, Building the CCA Tools and TAU and Setting Up Your Environment) then the bocca command is already in your command path and you are ready to go. Find a safe place to begin your bocca project, such as your WORKDIR:



$  cd $WORKDIR




$ 


The first thing to do is to create a project directory within which all of your components and ports will reside. Normally you would choose a relevant project name but for now we will just call it myProject. Create the project directory now:



$  bocca create project myProject --language=LANG




The project was created successfully in /data/user1/myProject
$ 


Here LANG is the implementation language that your components will default to. Just choose the one of c, cxx, or f90 with which you are most comfortable. (The default language can actually be any language that bocca and Babel are configured to support, but currently this Guide includes detailed instructions for only C, C++, and F90.) If no language option is given, C++ will be used as the default project language. Note that a project with a given default language can contain components implemented in any Babel-supported language.

Now that the project is created, we see that bocca has created a lot of build scaffolding to support the componentized application we will write. The first thing you notice is that bocca has created a directory:



$  ls




myProject
$ 


Feel free to poke around a bit:



$  ls myProject/




BOCCA	    configure	  install	make.project.in  ports
buildutils  configure.in  Makefile	make.rules.user  README
components  external	  make.project	make.vars.user	 utils
$ 


Before using a new bocca project or working with an existing project just checked out from a source code repository, you will need to configure it for the details of your local environment. For a new project this is easy: ./configure from within your new project directory.



$  cd myProject; ./configure




checking for bash... /bin/sh
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for openpty in -lutil... yes
checking for bocca... /home/baallan/cca/build/bocca/trunk/install/bin/bocca
c cxx f90 f77 python
configure: Configuring with languages: c cxx f90 f77 python
configure: Project source dir apparently /data/user1/myProject
configure: Using 1 processe(s) in calls to make.
checking whether make sets $(MAKE)... yes
configure: creating ./config.status
config.status: creating make.project
config.status: creating buildutils/make.vars.common
config.status: creating utils/run-gui.sh
config.status: creating utils/bocca-gui-backend.sh
config.status: creating utils/myProject-config
config.status: creating utils/config-data
config.status: executing outmsg commands
$