next up previous contents
Next: Accessing SIDL Arrays From Up: FORTRAN 90 Bindings Previous: Calling Methods From FORTRAN   Contents

Implementing Classes in FORTRAN 90

Much of the information from the previous section is pertinent to implementing a SIDL class in FORTRAN 90. The types of the arguments are as indicated in Table 11.1. Your implementation can call other SIDL methods in which case follow the rules for client calls.

You should invoke BABEL:

% babel -server=f90 file.sidl

This will create a babel.make, numerous C headers, numerous C source files and some FORTRAN 90 source files. Your job is to fill in the FORTRAN 90 source files with the implementation of the methods. The files you need to edit all end with _Impl.F90. All your changes to the file should be made between code splicer pairs. Code between splicer pairs is retained by subsequent invocations of BABEL; code outside splicer pairs is not.

Here is an example of the standard code splicer pairs in generated FORTRAN 90 code. You would replace the comment "Insert extra code here... " associated with the "miscellaneous code start" splicer pair with code needed for your implementation such as additional abbreviation file(s) and any local, or private, subroutines. For the subroutine's "use" splicer pair, you would replace the "Insert use statements here..." comment with any use statements that are needed by the subroutine. Finally, you would add the implementation between the subroutine body's splicer pairs in the place of the "Insert the implementation here..." comment.

users_guide/f90/code/splicer_pair.F90

Each _Impl.F90 file contains numerous partially implemented subroutines. The SUBROUTINE and END SUBROUTINE statements have been generated and the types of the arguments declared. As mentioned above, you must provide any needed use statements and the body of each subroutine to implement the expected behavior of the method.

There are two implicit methods (i.e. methods that did not appear in the SIDL file) that must also be implemented if the object is to have state. The _ctor() method is a constructor function that is run whenever an object is created. The _dtor() method is a destructor function that is run whenever an object is destroyed. If there is not state then these functions are typically empty.

The SIDL IOR keeps a pointer (i.e. C void *) for each object that is intended to hold a pointer to the object's internal data. The FORTRAN 90 skeleton provides two functions that the FORTRAN 90 developer will need to use to access the private pointer. The name of the function is derived from the fully qualified type name by replacing periods with underscores and appending __get_data_m or __set_data_m. The first argument is the object pointer (i.e. self), and the second is an opaque. The number of bits used in FORTRAN 90 depends upon the size of SELECTED_INT_KIND(18), while the number of bits stored by the IOR is determined by the sizeof(void *).

BABEL/SIDL does not provide a mechanism for FORTRAN 90 to allocate memory to use for the private data pointer.


next up previous contents
Next: Accessing SIDL Arrays From Up: FORTRAN 90 Bindings Previous: Calling Methods From FORTRAN   Contents


babel-0.8.0
users_guide Last Modified 2003-01-14

http://www.llnl.gov/CASC/components
components@llnl.gov