Ftcl: Design considerations

Design of interface, some personal notes

The goal was to design a simple and robust interface. The first version I had in mind was one in which there would be a repository. I could have used the pointer facilities that exist in Fortran 90 to associate Tcl variable names with Fortran variables, but that means that the Fortran programmer has to take care that the variables remain in existence for the duration of the program.

So then I decided to keep a copy of the values, rather than a pointer to those values. The Fortran programmer then had to worry about passing on the values of the exported variables and arrays of course, but that is better than having crashes that are difficult to trace.

With this set-up Tcl scripts could query the repository or store new values. The main advantage would have been a controlled transfer of data. The drawbacks are the responsabilities for the programmer and the added complexity of maintain such a repository and the fact that each value would have been present three times (once in Tcl, once in specific Fortran routines and once in the repository).

Instead, a much simpler interface has been implemented: Fortran routines have direct access to the Tcl variables. In fact, the mechanisms Tcl provides for manipulating variables are being used for maintaining the repository.

Tcl scripts, on the other hand, have only very limited access to Fortran variables, that is, via a process controlled from the Fortran side. But I think this is quite a good situation: Tcl scripts should know little from the inners of the packages they use.