Modulefpreviousupnextcontentsindex[BIG][Normal][small]
Next: 1.6 Data Structures Up: 1 General Prev: 1.4 Function interpreter Index Contents


1.5 Dynamic arrays

   

Dynamic arrays are the concern of the developer of new modules, rather than the user of existing modules. The latter merely needs to write a main program, as indicated in figure 1.2.

 
Figure 1.2: Example of a main program 

The program consists of:

The notion of arrays is very current in programming for developers of new modules. Nevertheless, the Fortran arrays are inconvenient as they are totally static: it is, for example, impossible to read an integer, N, and then to declare an array, T, containing N real values. ([note] In C this is written as: t = (float*)malloc(n*sizeof(float))) The approach consisting of sub-dimensioning each array becomes unusable as soon as the number of arrays becomes too large. Another approach, adopted by MODULEF, consists of generating all the dynamic arrays within the same static array (figure 1.3).

 
Figure 1.3: MODULEF dynamic arrays 

This unique static array, called the super-array  M, is declared in the main program and is passed as a parameter to all modules. Some modules, however, escape this rule, explaining the use of the COMMON statements.

A certain number of utilities are available to create, delete, or "visualize" dynamic arrays. This type of management is facilitated by employing a symbolic name associated with each array (see TAB, appendix A). In reality, each array is located by its address, IATAB, in the super-array: the creation utility returns an index, IATAB, such that M(IATAB) corresponds to the first element of the array created.

The super-array may contain different types of arrays (integer, real, double precision, etc.) Consequently, a few precautions are necessary:


Modulefpreviousupnextcontentsindex[BIG][Normal][small]
Next: 1.6 Data Structures Up: 1 General Prev: 1.4 Function interpreter Index Contents