Next: 4 Data Structures
Up: 3 Dynamic arrays
Prev: 3.4 Programming with dynamic arrays
Index
Contents
The addresses and the lengths of arrays are given in words, which poses a few problems with real double precision.
Suppose that, using the usual notation (appendix A), M, XM, and DM represent the same super-array of type INTEGER, REAL, and DOUBLE PRECISION.
After allocating a dynamic array in double precision, utility READRE always returns an odd index IATAB.
The first element of this array is referenced by M(IATAB), XM(IATAB), or DM((IATAB+1)/2).
Element, I, of this array is referenced by M(IATAB-1+I), XM(IATAB-1+I), or DM((IATAB-1)/2+I).
This last form is rather heavy. Recall that a more elegant solution consists of passing M(IATAB) as a parameter (section 3.4).
The programmer must consider allocating an array of length LTAB = NBELEM*NBREMO, where NBELEM is the number of elements in the array (which appears in the Fortran declarations) and NBREMO is the number of words occupied by a real double precision scalar (in general 2).
Furthermore, certain compilers allow us to inhibit type DOUBLE PRECISION by replacing it automatically by type REAL (especially on "super-computers" with 64 bit words).
The instruction:
CALL READRE(5, TAB, IATAB, LTAB, M, ICODE)
must then be replaced by:
CALL READRE(2, TAB, IATAB, LTAB/2, M, ICODE)
The following sequence avoids the modifications:
NTYTAB = IINFO('REEL2')CALL TYPMOT(NTYTAB, NBREMO)
CALL READRE(NTYTAB, TAB, IATAB, NBELEM*NBREMO, M, ICODE)
where:
This sequence is longer than the simple instruction seen previously, but more readable and portable!