The SCF process has two phases which are totally disjoint, the array of contributions to the energy functional, and the array of integral values may share the same memory.
To maximize the memory utilization, the storage of all arrays is allocated in a stepwise fashion. Upon memory allocation failure, the remaining arrays are stored on disk. Under this scheme the order in which arrays are allocated becomes important and the arrays used most frequently at each SCF iteration are allocated first. The angular coefficient data and the interaction matrix are the two major data structures which define the memory use for each scf iteration. As the number of configurations grows the memory capacity may be exceeded thus requiring some or most of the data to be stored on disk. Disk read/write operations are then performed on each SCF and DVDSON iteration. Disk read/write access is considerably slower compared to memory access. In order to accomplish high computational efficiency it is essential to avoid disk I/O and keep all data in memory. Therefore, optimizing mchf for large scale calculations requires management of the disk/memory data storage. In general, the angular coefficients, the interaction matrix elements and the associated pointers are stored in one dimensional arrays. The arrays of angular coefficients are considerably larger than the interaction matrix.
The memory allocation process (alcsts), starts with Level 4 and upon success on each level may proceed up to Level 1. At Level 4, if no memory is available for performing Dvdson iterations on disk (vector-matrix multiplication on disk) the program exits. (This will represent a very large case beyond practical limits for serial computing: in the order of millions of cfgs). If the program cannot proceed with allocating memory for the interaction matrix of the largest block, a similar, local scheme (in diag) is used to allocate memory for each block. Blocks can vary significantly in size and in order to improve the performance mchf is designed to keep smaller blocks in memory if possible.
As shown in table 6.3, levels 1, 2, and 3 ico has higher priority compared to coeff and inptr because ico is used in both diag and updatc routines. However, it is important to note that updatc proceeds almost always in memory since all of the memory used in diag_hmx and dvdson is deallocated and made available.
The memory allocation procedure relies on malloc() and free(), which are C routines normally used for dynamic memory management. malloc() allocates size bytes and returns a pointer to the allocated memory. If the request fails malloc() returns a NULL pointer. The atsp2K package includes the routines alloc() and dalloc() which use a similar approach, however upon failure alloc() aborts by calling EXIT(). mchf has several levels of memory allocation requiring the returned pointer to be monitored in order to adjust the subsequent memory requests. For this purpose two routines specific only to mchf have been introduced: diag_allocate() and diag_deallocate(). If the memory is not sufficient for loading the array under consideration in the memory, then, memory for the largest column of that array is allocated and the array is stored on disk.