Next: Mathematical Formula Handling Up: Using Variables Previous: Definition   Contents   Index

## Assignment and Examination

SIC variables can be assigned new values, and examined using the following routines.

```          Argument Data Type      Assignment    Examination Subroutine
REAL(kind=8)            SIC_LET_DBLE   SIC_GET_DBLE
REAL(KIND=4)            SIC_LET_REAL   SIC_GET_REAL
INTEGER(KIND=4)         SIC_LET_INTE   SIC_GET_INTE
LOGICAL(KIND=4)         SIC_LET_LOGI   SIC_GET_LOGI
CHARACTER(LEN=*)        SIC_LET_CHAR   SIC_GET_CHAR

The calling syntax is the following
CALL SIC_LET_Name (NAME,VARIABLE,ERROR)
CALL SIC_GET_Name (NAME,VALUE,ERROR)
except for SIC_GET_CHAR
CALL SIC_GET_CHAR (NAME,STRING,LENGTH,ERROR)
```
These a-priori useless routines can be used to modify variables defined in completely independent parts of a program such as the codes supporting two different SIC languages. For example the GRAPHIC language interacts with GREG1 and GREG2 through SIC variables.

For assignment routines, the data type of the VARIABLE argument and of the SIC variable must match exactly. For retrieving routines, the data type to specify is the type of the VALUE argument; implicit conversion from the type of the SIC variable is done if possible, an error is returned otherwise.

Only SCALAR variables can be assigned or examined in this way. For ARRAY variables, you should use the subroutine SIC_DESCRIPTOR.

```          CALL SIC_DESCRIPTOR (VARIABLE,DESC,FOUND)

- VARIABLE (input) is the variable name (general syntax A[i,j]
allowed)
- DESC (output) is the descriptor of the variable, an instance of
the derived type 'SIC_DESCRIPTOR_T' provided by the module
'GKERNEL_TYPES', containing:
DESC%TYPE     Variable type:
* DESC%TYPE > 0 : Character string of length DESC%TYPE
* DESC%TYPE < 0 may have the value
FMT_R4 for REAL(KIND=4) variable
FMT_R8 for REAL(KIND=8) variable
FMT_I4 for INTEGER(KIND=4) variable
FMT_I8 for INTEGER(KIND=8) variable
FMT_L  for LOGICAL(KIND=4) variable
FMT_BY for INTEGER(KIND=1) variable
FMT_C4 for COMPLEX(KIND=4) variable
DESC%NDIM     Number of dimensions
DESC%DIMS(7)  Dimensions
DESC%SIZE     Size of allocation (4-bytes words)
DESC%STATUS   Origin of variable
0       program defined
< 0     user defined
> 0     image
- FOUND (output) is a logical indicating whether the specified
variable exists or not.
```

The parameters FMT_R4, FMT_R8, FMT_I4, FMT_I8, FMT_L, FMT_BY and FMT_C4 are defined in the module gbl_format.

Three other routines may be required for variable handling:

```        CALL SIC_MATERIALIZE(VARIABLE,DESC,FOUND)
```
is like SIC_DESCRIPTOR, but allow implicit transposition and sub-arrays in the variable name. An intermediate variable will be created to handle such cases.

SIC_INCARNATE is used to create an ``incarnation'' of a variable under a specified type (REAL, DOUBLE, INTEGER).

```        CALL SIC_INCARNATE(FORM,DESC,INCA,ERROR)
where
- FORM is the format of the desired incarnation (FMT_R4, FMT_I4
or FMT_R8)
- DESC is the descriptor of the variable
- INCA is the descriptor of the incarnation
- ERROR is a logical error flag
```

DESC and INCA are instances of the derived type SIC_DESCRIPTOR_T. DESC should have been obtained by a previous call to SIC_DESCRIPTOR.

Once used, the materialization or incarnation may be deleted using routine SIC_VOLATILE

```    CALL SIC_VOLATILE(INCA)
where
- INCA is the descriptor of the incarnation/materialization.
```

Next: Mathematical Formula Handling Up: Using Variables Previous: Definition   Contents   Index
Gildas manager 2014-07-01