5. Examples of use#

In this part, we will assume to have placed ourselves in an application environment (for example that of ASTER) and to have opened the databases associated with the classes G, V and L. We will only mention the calls to the JEVEUX routines, the declarations and the Fortran commons are omitted.

5.1. Creation and reuse of a real vector#

Consider the following problem: we want to create (in routine SUBA) a real vector containing the coordinates \(X\) and \(Y\) of \(\mathit{nno}\) nodes. We’ll call this vector “COORDO_XY” and we’ll reuse it in the SUBB routine.

SUBROUTINE SUBA (...)

...

#include « I want to. » real (kind=8), pointer:: COOR (:) => null ()

! - Start of instructions:

  1. CALL JEMARQ ()

! - Vector allocation based on “GLOBALE”:

  1. CALL WKVECT (“COORDO_XY”, “G V R”, 2*nno, vr= COOR)

! - « vector padding »

OD ino = 1, no

COOR (2* (ino-1) +1) = X

COOR (2* (ino-1) +2) = Y

ENDDO

  1. CALL JEDEMA ()

END

SUBROUTINE SUBB (…)

real (kind=8), pointer:: COOR (:) => null ()

! - Start of instructions:

  1. CALL JEMARQ ()

! - Retrieving the vector address (in reading):

  1. CALL JEVEUO (“COORDO_XY”, “L”, vr= COOR)

! - Retrieving the coordinates of the 27th node:

X27 = COOR (2 * 26 + 1)

Y27 = COOR (2 * 26 + 2)

  1. CALL JEDEMA ()

END

Comments:

  • lines (a), (c), (d), (e): routines JEMARQ/JEDEMA: routines/allow objects to be automatically released at the end of routines [§4.11],

  • line (b):

  • “G V R”:

“G”: « Global » database (user database cf. [§3.3])

“V”: vector,

“R”: real,

*2*nno: vector length

  • COOR: pointer to the value segment

  • line (e)

  • “L”: « read » access to the object (cf. [§4.5]).

5.2. Creating a name directory and inserting two names#

CALL JECREO ('MES_NOMS', 'G N K8')

CALL JEECRA ('MES_NOMS', 'NOMMAX', ival=25)

C

CALL JECROC (JEXNOM ('MES_NOMS', 'NOM_1'))

CALL JECROC (JEXNOM ('MES_NOMS', 'NOM_5'))

C

CALL JELIRA ('MES_NOMS', 'NUTIOC', ival= IVAL)

CALL JENONU (JEXNOM ('MES_NOMS', 'NOM_5'), NUM)

CALL JENUNO (JEXNUM ('MES_NOMS ',1), NOM)

The call to JENONU returns the value 2 in the variable NUM, The call to JENUNO returns the value “NOM_1” in the variable NOM.

5.3. Scattered collection of integer vectors#

The objects in this collection are named in the directory, managed by the user, and created in the previous example; they are of variable length.

CALL JECROC (JEXNOM (“MA_COLL”, “NOM_13”)) CALL JEECRA (JEXNOM (“MA_COLL”, “NOM_13”), “LONMAX”, ival=125) CALL JEECRA (JEXNOM (“MA_COLL”, “NOM_1”), “LONMAX”, ival=250)

In another routine, we use the object “NOM_13” that was just created:

CALL JELIRA (JEXNOM (“MA_COLL”, “NOM_13”), “LONMAX”, ival= LNOM13)

C

DO 10K = 1, LNOM13 ZI (JTAB - 1 + K) = K

10 CONTINUE

CALL JEDETR (JEXNOM (“MA_COLL”, “NOM_13”))

The NUTIOC attribute of the collection is updated at the same time as that of the simple object “MES_NOMS”. The last instruction destroys the collection object “NOM_13” and the name in the “MES_NOMS” directory.

5.4. Contiguous collection of integer vectors#

The objects in this collection are named in the name directory “MES_NOMS”, which was already used for the two previous examples. They have a variable length defined by a length vector “LONGUEURS” managed by the user.

In a first routine, we create the collection and we add an object “NOM_24”

CALL JECREC ('MA_COLL', 'G V I', 'NO MES_NOMS ',' CONTIG ',' VARIABLE ',25)

CALL JECROC (JEXNOM ('MA_COLL', 'NOM_24'))

In another routine, we define the length of objects 2 to 25, equal to the object insertion number:

CALL JEVEUO ('LONGUEURS', 'E', JTAB)

C

DO 10 I = 2, 25

CALL JEECRA (JEXNUM ('MA_COLL', I), 'LONMAX', ival=I)

10 CONTINUE

In another routine, we define the length of object 1 (equal to 50), and we access the entire collection to define the 13th component of the first object:

CALL JEECRA (JEXNUM ('MA_COLL', 1), 'LONMAX', ival=50)

C

CALL JEVEUO ('MA_COLL', 'E', vi= TABC)

K = 13

TABC (K) =...

In another routine, we allocate the 2nd object to define all its components:

CALL JEVEUO (JEXNUM ('MA_COLL', 2), 'E', vi= TABOC)

CALL JELIRA (JEXNUM ('MA_COLL', 2), 'LONMAX', ival=L2)

DO 20 K = 1, L2

TABOC (K) =...

20 CONTINUE

In another routine, we allocate the entire collection to define the first component of the 3rd object, which is accessed by the vector of cumulative lengths:

CALL JEVEUO ('MA_COLL', 'E', JTABC)

C

CALL JEVEUO (JEXATR ('MA_COLL', 'LONCUM'), 'E', JTABCU)

C

IOBJ = 3

IAD = ZI (JTABCU - 1 + IOBJ)

ZI (JTABC - 1 + IAD) =...

Note the two ways in which you can define the length of a collection object:

  • using the call to JEECRA

  • by directly affecting the value in the length vector.

The first request to JEVEUO (in the last frame) accesses the globally contiguous collection and therefore returns the address of the first object, with the user having to move relative to this address to reach a particular object. The second request provides direct access to a collection object and returns the address of this object.

In the last example, we get the cumulative lengths of the objects in the collection, which allows the user to access any object, without multiplying JEVEUO requests.

Note:

In all three cases, all the objects in the contiguous collection are present in memory.