3. Access to value segments#
The content of a JEVEUX object is accessed using the jeveuo routine (or wkvect).
There are two different types of access for each of these routines:
access by « pointer »
access by « address in a reference variable »
The first access (allowed thanks to Fortran 2003) is now preferred
3.1. Pointer access#
When you want to access the content of a JEVEUX object, you declare a local variable of type « pointer » to a vector of the right type.
The call to jeveuo associates the pointer with the memory area occupied by the object (this one is then brought back into memory if necessary).
We can then manipulate the object as a simple Fortran vector.
Example: Read access to the coordinates of the mesh nodes:
! declaration of the local variable:
real (kind=8), pointer:: coordinate (:) => null ()
…
Call JeVeuo (ma///. COORDO. VALE “,” L “, vr=coordindo)
n1=size (coordinate)! Access to the length of the object (=3*nbno)
Do ino=1, nbno
x=coordinate (3* (ino-1) +1)
Y=coordinate (3* (ino-1) +2)
…
Enddo
Important note:
When declaring the local variable (here: coordindo), it is mandatory to initialize the pointer to « zero » (=> null ()). Otherwise, the pointer is in an undetermined state.
3.2. Access by address#
The jeveuo and wkvect routines can return to the user a relative address in one of the tables \(\mathit{ZR}\), \(\mathit{ZI}\), \(\mathit{ZC}\), or \(\mathit{ZK}\), (one of these Fortran variables will later be noted \(Z?\)). This address is valid as long as there is no release.
The concept of write or read access makes it possible to avoid the systematic unloading of the value segment onto disk and thus limits the number of inputs/outputs on disk. Read-accessed objects will not be saved to disk at the time of release. The call to WKVECT makes a write request.
A value segment could be accessed by writing and then freed, the manager then keeps it in memory and defers its unloading on disk during a next search for space. A new read access returns the address of the downloadable segment, so a modification of the content can take place without the user’s knowledge if the user assigns the content of table \(Z?\) to the address indicated.
Rule of use:
The user, when performing a read access, must not modify the content of the table \(Z?\) at the address provided during the request and must avoid passing it as an argument to a subroutine over which he does not have full control.
The call to the jeveuo routine returns the address of the object JEVEUX relating to a variable \(Z?\) of the same type as the object JEVEUX (this address is measured in the length of the type).
The standard common should be in any program unit that makes this type of call.
Since version NEW11 .2.2 this common is inserted into the sources by the instruction:
#include « I want to. »
which will automatically replace the following instructions during the compilation:
INTEGER ZI
COMMON/IVARJE /ZI (1)
INTEGER *4 ZI4
COMMON /I4 VAJE/ZI4 (1)
REAL *8 ZR
COMMON/RVARJE /ZR (1)
COMPLEX *16 ZC
COMMON/CVARJE /ZC (1)
LOGICAL ZL
COMMON/LVARJE /ZL (1)
CHARACTER *8 ZK8
CHARACTER *16 ZK16
CHARACTER *24 ZK24
CHARACTER *32 ZK32
CHARACTER *80 ZK80
COMMON/KVARJE/ZK8 (1), ZK16 (1), (1), ZK24 (1), ZK32 (1), ZK80 (1)
Note:
Do not change the name of the variables of the common reference.
Access to a value segment is achieved as follows: if \(\mathit{JTAB}\) designates the address returned by the JEVEUO routine for an object of vector type and type \(I\), \(\mathit{KTAB}\) that for an object of type \(C\) (complex):
.
\(\mathit{ZI}(\mathit{JTAB})\) |
is the first value of an integer vector, |
\(\mathit{ZI}(\mathit{JTAB}+I\mathrm{-}1)\) |
is the \(I\) value of an integer vector, |
\(\mathit{ZC}(\mathit{KTAB}+I\mathrm{-}1)\) |
is the \(I\) value of a complex vector. |
Variables (JTAB) that may contain an address JEVEUX and used as arguments to routines in the form ZI (JTAB), ZR (JTAB), etc., must always be initialized to the value 1. Thus, if this address is not the result of a call to JEVEUO or WKVECT, we will point to a valid value for the first element in the sense of memory access. ZI (1), ZR (1), and ZC (1) are initialized with a value that may cause an error or an operation leading to NaN.