Next: 5 Diverse utilities
Up: 4 Data Structures
Prev: 4.1 Utilization
Index
Contents
The programmer must know the internal presentation of the DS, as well as the utilities manipulating them.
A DS is a set of arrays residing in main or secondary memory. The significance of the information contained in these arrays depend on the type of DS (Part iii). In this manner, a NOPO type DS contains a mesh, a MUA type DS contains a "skyline" matrix, etc.
This section describes the names of these arrays and their respective contents.
When an array is present in main memory, it forms part of a DS and a dynamic array. Its name is formed of four characters:
For example, when a MAIL type DS with level 0 is read into main memory, 22 dynamic arrays are present: MA00, MA01, ..., MA09, MA0A, MA0B, ..., MA0L.
The names, addresses and lengths of all these arrays are contained in a unique array, of which the name ends with a percentage character (in our example, MA0%).
In addition, the programmer has the possibility to create arrays associated with the DS. These arrays are referenced by Array 1 (see below) and are manipulated by the various utilities at the same time as the other arrays. This enables the transfer of information between specific modules.
Whatever the DS type, the significance of arrays %, 0 and 1 is always the same. Those of the other arrays present some similarities. The description of all these arrays is given below.
This array is used when the DS is in main memory.
It contains 1 + 3 n integers,
where n is the number of dynamic arrays which form the DS
(without counting Array % and the associated arrays).
Some of these integers in fact contain
4 characters, coded with the aid of utility
ICHAR4 (p. ).
The following description gives, for each integer, its traditional Fortran identifier,
its length and its contents.
This array contains 32 integers:
If NTASD = 0 (see "Array 0"), then this array is absent.
If not, it occupies 22 NTASD integers and contains
the description of the arrays associated with the DS:
This array contains the general information (for example: the number of elements, the number of degrees of freedom, the length of the arrays which follow, etc.).
These arrays contain, either "pointers" to the arrays which follow, or the values themselves (for example: mesh point coordinates, mesh coefficients, etc.).
The number and the contents of the associated arrays are totally dependent on the programmer.
During the programming of a new module, a certain number of utilities are necessary for the manipulation of the DS.
Generally speaking, a module reads a IDS, allocates the arrays that will constitute the ODS, calls an algorithms, and writes the ODS (section 1.7.2). The manipulation operations of the DS are done with the help of utilities: INICSD, SDREST and SDSAUV.
During the creation of a new DS, utilities COPISD, COTASD and INTAB0 can also be called.
All these utilities manipulate Array % of the DS under consideration (section 4.2.1) and a copy of this array at the same time. The first is a dynamic array of which the name is contained in variable NC and the address in variable IC. The second is found in a classical Fortran array, declared by the programmer, which is traditionally called NZ. In the remainder, these two arrays are respectively called array % and array NZ.
The notation used for the utilities below |
is the usual notation (see Appendix A). |
SUBROUTINE COPISD(,
,
,
,
,
,
,
,
)
INTEGER M(*), NTAB, NI1, NC1, IC1, NI2, NC2, IC2
CHARACTER*4 TYSD
This utility copies the NTAB first arrays from DS 1 to DS 2.
Let n be the total number of arrays in DS 1 (Part iii of this user guide gives the total number of arrays for a given type of DS).
NTAB = n corresponds to a total copy, and NTAB < n, to a partial copy.
SUBROUTINE COTASD(,
,
,
,
,
)
INTEGER M(*), NTAC, NBTASD, NTAB1, IATAB1, LTAB1
This utility creates the arrays associated with a DS. It allocates NTAC associated arrays, reads them in free format, and creates Array 1 of the DS.
NBTASD is the total number of associated arrays. NTAC is equal to NBTASD, except in the exceptional case where the arrays are associated by program.
NTAB1, IATAB1 and LTAB1 are respectively the name, address and length of Array 1 in the DS.
SUBROUTINE INICSD(,
,
,
,
,
,
)
INTEGER M(*), NI, NZ(LZ), LZ, NC, IC
CHARACTER*4 TYSD
This utility initializes array NZ in an ODS, i.e:
SUBROUTINE INTAB0(,
,
,
)
CHARACTER*4 TYSD
INTEGER NI, NBTASD, NTAB0(32)
This utility initializes the 32 elements of array NTAB0, where Array 0 of the new DS has NBTASD associated arrays.
SUBROUTINE SDREST(,
,
,
,
,
,
,
)
INTEGER M(*), NF, NI, NZ(LZ), LZ, NC, IC
CHARACTER*4 TYSD
This utility restores an IDS, i.e:
In certain cases, SDREST only reads the first arrays in the DS (see section "DS of Category 1 or 2" below).
SUBROUTINE SDSAUV(,
,
,
,
,
,
,
,
)
INTEGER M(*), NF, NI, NZ(LZ), LZ, NC, IC, NMO
CHARACTER*4 TYSD
This utility saves a DS, i.e:
In certain cases, SDSAUV only writes the first arrays of the DS (see section "DS of Category 1 or 2" below).
The form of a model transforming an IDS AMAT into an ODS MUA is the following:
SUBROUTINE TAMMUA(M, NFAMAT, NIAMAT, NFMUA, NIMUA) C --- M : SUPER-ARRAY C --- NFAMAT, NIAMAT : FILE AND LEVEL OF THE IDS AMAT C --- NFMUA, NIMUA : FILE AND LEVEL OF THE ODS MUA INTEGER M(*) INTEGER NZMUA(19),NZAMAT(22) CHARACTER KINFO*80, CHAR4*4 1000 FORMAT(1X,78('&')/' MODULE TAMMUA : ',20A4/1X,78('&')) C --- PRINT THE TITLE IMPRIM = IINFO('I') IMPRE = IINFO('BAVARD') IF (IMPRE.NE.0) WRITE (IMPRIM,1000) KINFO('TITRE') C --- RESTORE THE IDS AMAT CALL SDREST(M,'AMAT',NFAMAT,NIAMAT,NZAMAT,22,NCAMAT,ICAMAT) C --- GET THE NECESSARY ADDRESSES IAMA0 = NZAMAT(3) IAMA1 = NZAMAT(6) IAMA2 = NZAMAT(9) ... C --- ALLOCATE THE ARRAYS OF THE ODS MUA CALL INICSD(M,'MUA ',NIMUA,NZMUA,19,NCMUA,ICMUA) NZMUA(4) = 32 CALL READRE(1,CHAR4(NZMUA(2)),NZMUA(3),NZMUA(4),M,NRET) ... C --- CALL THE ALGORITHM CALL ALGO(M(IAMA2), M(NZMUA(3)), ...) C --- SAVE THE ODS MUA CALL SDSAUV(M,'MUA ',NFMUA,NIMUA,NZMUA,19,NCMUA,ICMUA,I) END SUBROUTINE ALGO(AMA2, MUA0, ...) C --- ALGORITHM CALLED BY MODULE TAMMUA INTEGER AMA2(10), MUA0(32), ... NTDL = AMA2(1) NTY = AMA2(2) NOE = AMA2(8) MUA0(32) = ... ... END
A widespread trick, which is to be avoided, consists of adding the COMMON and EQUIVALENCE commands. For example:
C --- PROGRAMMING NOT ADVISABLE !!! INTEGER NZMUA(19) COMMON /ALMUA/ NEMUA, & NMUA0, IAMUA0, LMUA0, NMUA1, IAMUA1, LMUA1, & NMUA2, IAMUA2, LMUA2, NMUA3, IAMUA3, LMUA3, & NMUA4, IAMUA4, LMUA4, NMUA5, IAMUA5, LMUA5 EQUIVALENCE (NZMUA(1), NEMUA)
The EQUIVALENCE command allows us to write NMUA0, IAMUA0, LMUA0, ... rather than NZMUA(2), NZMUA(3), NZMUA(4), ... However, the above programming does not indicate clearly that array NZMUA is modified itself.
The COMMON /ALMUA/ command allows all the sub-programs to access array NZMUA. However, when several DS of the same type are in use, array NZ may be deleted involuntarily, and it furthermore becomes impossible to parallelize the program.
There are in fact two DS categories:
(DS of type BDCL, FORC, GEOM, MILI, NOPO, see Part iii).
(DS of type AMAT, ATRI, B, COOR, MUA, TAE, TYNO, VVPR, see Part iii).
The functioning of the utilities
SDREST (p. )
and SDSAUV (p.
)
is slightly different for a category 2 DS, :