### 18.6.1. Introduction to the Memory Management System

This introduction to the memory management system, as used in the CFX-Solver, enables you to operate on and pass around your own data structures between user routines.

All arrays (except perhaps for very small local arrays) are stored in global stacks, there being one stack for REAL (RZ), one for DOUBLE PRECISION (DZ), one for INTEGER (IZ), one for CHARACTER (CZ), and one for LOGICAL (LZ). Similarly, any scalar variables that are not local may be stored in a stack. Such sections of the stack (arrays or individual scalars) be referred to as data areas.

The total number of data areas available in the memory management system, also referred to as the catalogue size, can be set by the programmer.

Within each stack, data areas can be created and deleted, but each individual data area will be contiguous.

When data areas are deleted, holes appear in the stack, but the stack catalogue is managed so as to ensure that no two holes are adjacent (that is, holes will be merged). A new data area will usually be placed in the smallest hole available, which is large enough to contain it.

Some data areas can be flagged as “vulnerable” so that, when the stack is full, one or more of these will be deleted automatically to make space. However, if the stack does not become full then all vulnerable data areas will remain unchanged.

The naming convention for data areas follows a UNIX-like structure, employing the concept of directories. Thus, a data area can be referred to by its full pathname /TIME-0/ GRID2/ VEL, say, or by its local name VEL, provided the current directory is /TIME-0 /GRID2/. It is also possible to refer to data areas and directories using relative pathnames, GRID2/ VEL, say, if the current directory is /TIME-0/. As in UNIX, the current and parent directories may be referenced by the character strings ‘.’ and ‘..’. Note that ‘/’ is referred to as the home directory, and that ‘HOME’ is not allowed as a directory or data area name.

There are utilities available for changing the current directory, pushing and popping to directories, creating new directories, creating new data areas, and so on. It is also possible to link directories and data areas.

Data area and directory names are currently limited to, at most, MXDNAM = 20 characters. Full pathnames of directories and data areas are currently limited to at most MXPNAM = 200 characters. MXDNAM and MXPNAM are both declared in the include file MMS.h, which should be included in all routines requiring character variables of these lengths to be declared.

Example:

    #include "MMS.h"
          CHARACTER*(MXDNAM) VARNAME
          CHARACTER*(MXPNAM) PATHNAME
          ....
          ....
          VARNAME = 'MY_VARIABLE'
          PATHNAME = '/USER_DATA/MY_VARIABLE'

As some compilers save local variables, the use of character variables of length MXPNAM should be kept to a minimum.

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