Modulefpreviousupnextcontentsindex[BIG][Normal][small]
Next: 4.2 Programming Up: 4 Data Structures Prev: 4 Data Structures Index Contents


4.1 Utilization

   

Calling a module generally has the form:

CALL MODULE(M, NF1, NI1, NF2, NI2, ...)

In this manner, each DS is referenced by two integers, NF and NI, where:

NF
is the file number: unit number of an open file, or 0 if the DS is in main memory;
NI
is the level number, which enables us to distinguish between two DS in main memory.

Furthermore, certain utilities may be called from outside the modules: IMtysd, NOFOSD, and TUERSD.

This section investigates these different notions.

4.1.1 File number: NF

 

This section describes the cases NF = 0 and NF , and then gives some indications regarding the options to choose from.

Case NF = 0 (main memory)

Conventionally, NF = 0 signifies that the DS resides in main memory.

In particular,

Case NF 0 (secondary memory)

Conventionally, NF signifies that the DS resides in secondary memory (disk file).

In particular,

The sign of NF specifies the access mode: NF > 0 for a sequential access file, NF < 0 for a direct access file. ([note] For a direct access ODS, first call utility DEFDIR (p. gif).) Certain modules offer a choice between two access modes in this manner, but the majority only accepts sequential access.

In all cases, the absolute value |NF| corresponds to the file unit number. The file must be previously opened by a call to OUVRIR or OUVRIS (section 1.6).

Choice between NF = 0 and NF 0

4.1.2 Level number: NI

 

Whatever the file number NF may be, a DS must be present in main memory to be manipulated. The DS is identified by its level number, an integer between 0 and 36. ([note] This limitation is due to utility NUMALP (p. gif).)

Example

The aim is to obtain a mesh of disc D by "gluing together" the three sectors, A, B and C (figure 4.1).

 
Figure 4.1: Disc D formed by three sectors A, B and C 

The three sectors, A, B and C, and the disc, D, to be created are described by a NOPO type DS. Assume that the corresponding files with numbers, NFA, NFB, NFC and NFD respectively, are already open. Assume also that a module, called RECOL,([note] The actual MODULEF module used for "gluing together" meshes is called RECOLC and needs a larger number of parameters.) "glues together" the meshes contained in two IDS, X and Y, and creates an ODS Z:

SUBROUTINE RECOL(M, NFX, NIX, NFY, NIY, NFZ, NIZ)

A solution is to read DS A with level 1, and DS B with level 2, and to create a DS with level 3 by "gluing together" A and B. The result is then "glued together" with DS C with level 4, thus creating the DS D sought, with level 5:

...

CALL RECOL(M, NFA, 1, NFB, 2, 0, 3)

CALL RECOL(M, 0, 3, NFC, 4, NFD, 5)

...

After these two calls, five DS reside simultaneously in main memory, referenced by their level numbers 1 to 5. If the size of the super-array is insufficient, it is preferable to delete the DS that become unnecessary (utility TUERSD, p. gif):

...

CALL RECOL(M, NFA, 1, NFB, 2, 0, 3)

CALL TUERSD(..., 1, ...)

CALL TUERSD(..., 2, ...)

CALL RECOL(M, 0, 3, NFC, 4, NFD, 5)

...

In fact, the level number only serves to distinguish between two DS of the same type: if two DS of different types reside simultaneously in main memory, they may have the same level numbers.

Therefore, in the preceding example, the DS are of the same type: NOPO. It is possible to use a DS MAIL with the same level (1 to 5) in the same program.

Convention concerning the modules

Many modules allow us to give the same level number to an IDS and an ODS of the same type. In this case, the IDS is killed and replaced by the ODS.

4.1.3 Utilities required by the user

     

The user can print a DS ( IMtysd), format a DS ( NOFOSD), or free the space in memory ( TUERSD).

The notation used for the utilities below
is the usual notation (see Appendix A).

Utility IMtysd

  

SUBROUTINE IMtysd( , , , )

INTEGER M(*), NF, NI, IMPRE

This utility prints the contents of the arrays of a DS, where IMPRE is the print parameter from 0 to 10:

IMPRE = 0
prints no arrays,
IMPRE = 1
prints array 2,
IMPRE = 2
prints, in addition, array 0,
IMPRE = 3
prints, in addition, array 1 and the "small" arrays,
IMPRE = 4
prints, in addition, the associated arrays,
IMPRE = 5 to 8
prints, in addition, the 10 first parameters of the "big" arrays,
IMPRE = 9 to 10
prints all the arrays completely.

Processor IMAGXX determines the DS type and calls the appropriate printing utility ( IMNOPO, IMMUA, IMB, ...).

Utility NOFOSD

  

SUBROUTINE NOFOSD( , , , , , , )

INTEGER M(*)

REAL XM(*)

DOUBLE PRECISION DM(*)

INTEGER NF1, NF2, NI, NOPT

In general, the DS are saved on "unformatted"([note] Fortran keyword: UNFORMATTED, i.e. binary.) files rather than "formatted"([note] Fortran keyword: FORMATTED, i.e. ASCII.). This choice is more efficient, but may pose problems when the same file is used by different computers (for example: a work station for the pre- and post-processing, and a super-computer for computation).

The solution adopted consists of using intermediate files which are formatted. More precisely, to transfer a DS from computer A to computer B which is incompatible with A, the following steps must be followed:

  1. Format the DS on computer A.
  2. Transfer the formatted DS from computer A to computer B.
  3. Unformat the DS on computer B.

The formatting and unformatting operations are performed by preprocessor
[4] NOFOXX, which calls utility NOFOSD:

Utility TUERSD

  

SUBROUTINE TUERSD( , , , )

INTEGER M(*), NI, NOPT

CHARACTER*4 TYSD

This utility frees the memory space occupied by a DS.


Modulefpreviousupnextcontentsindex[BIG][Normal][small]
Next: 4.2 Programming Up: 4 Data Structures Prev: 4 Data Structures Index Contents