Array and Safe Array Fundamentals
Arrays have always been one of the most important data structures in programming languages. Because of this, the evolution of programming languages has also involved important changes in the way arrays are handled. Older compilers could only handle fixed arrays (i.e. arrays which dimensions and base data type were set, fixed, at compile time). On the other hand, most new computer language standards offer some form of dynamically allocated arrays. Handling dynamically allocated arrays is a little more complicated than working with fixed arrays for both programmers and compilers alike, but the advantages of dynamically allocated arrays are many and well worth the extra work.
The dynamic arrays used by Visual Basic are called Safe Arrays. This is also the same type of arrays used by the OLE/COM protocol. Fortran dynamic arrays are either allocatable-arrays or pointer-arrays. Visual Basic and Fortran arrays are basically incompatible, but interestingly enough, the underlying principles behind both types of arrays are very similar. f90VB’s Safe Arrays library exploits these similarities to allow your Fortran subroutines to directly work with and return Safe Arrays to Visual Basic applications.
In this chapter, we will review some basic concepts about Safe Arrays and Fortran arrays. The objective of this review is to give you the background information you need to comfortably use the functions and subroutines included in Canaima Software’s f90VB Safe Arrays library.
Visual Basic (OLE/COM) Safe Arrays and Fortran Dynamic Arrays
Safe Array representations in f90VB