### 18.6.3. Stack Pointers

Data on the stacks is often first accessed by name then manipulated efficiently by using a pointer. By convention, a stack pointer is a variable with a name starting with a small "`p`". It is declared as of type `_stack_point_`, for example:

    _stack_point_ pVAR

`_stack_point_` is a pre-processor macro that is currently equivalent to `INTEGER` but allows future extensions for long addresses. It can be accessed in any Fortran routine that contains the statement:

    #include "stack_point.h"

before the macro is first used.

Pointers are returned by routines that create new data areas (`MAKDAT`) or find existing data areas (`LOCDAT`). In each the caller specifies a name for the data, for example, `MY_VAR` and receives a pointer in return, for example, `pMY_VAR`.

It is recommended that stack pointers are used locally within a routine where they are obtained; there is a clear distinction between routines that use pointers and those that do not. These stack points should not be stored for future calls because it is not guaranteed that the referenced item will remain in memory at the same location.

It is common practice to pass a stack location, for example, `RZ(pVAR)`, as an argument down to another subroutine that can manipulate this data as an ordinary Fortran variable or array. For example:

          CALL MY_SUB( RZ(pMY_ARRAY), LEN_MY_ARRAY)
          ....
          ....
          SUBROUTINE MY_SUB( A, N )
             REAL A(N)
             DO I = 1, N
                A(I) = 0.0
             END DO
          END

Release 18.2 - © ANSYS, Inc. All rights reserved.