Memory Allocation Processes : qxmemory: and incrqx:

Some of the uses of the QX array have already been discussed above. The QX array must be used for all major data storage. The 'allocation of memory' is the Xtal jargon for the resetting of the maximum index of the QX array. The different ways that machines store the QX array in memory necessitate a special approach to the way this array can be indexed. Addressing QX with absolute indices (e.g. QX(23)) is not permitted. All references to QX must be via a relative index that started at a base value specified by the system variable QXSTR. QXSTR is initialized at the start of each calculation. On some machines QXSTR will be 1, but on others it will be several thousand words. The programmer must be disciplined in the application of memory allocation procedures, especially if software is being developed on a machine of the first category (where the absolute and relative addresses are the same).

The request to reset the index for QX is handled by the macros qxmemory: or incrqx:. For example, if symmetry matrices are to be stored in QX, the following sequence must precede the actual storage process.

MARKS=QXSTR+NSYM*12#                Set QX request for symops
IF(MARKS>QXMAX) iquit:(XX1234)#     Test if memory available
qxmemory:(MARKS)#                   Allocate memory for symops

or

incrqx:(MARKS,QXSTR+NSYM*12,XX1234)# Get memory for symops

Both these sequences are equivalent. Note that qxmemory: is useful in cases where memory requests are very large and may exceed QXMAX. The macro incrqx: will automatically quit in such cases whereas qxmemory: can be used to take corrective action. incrqx: is most useful when only small packets of data are being added repeatedly to the QX array (e.g. when storing atom or reflection data inside a loop) because memory is expanded in minimum increments of 1000 words. Here is a typical application of incrqx:.

ISTEPA=8#				Packet size in atom list
FOR(I=MARKA;;I=M)#			Loop over atoms list
$(#					>>>>>>>>>>>>>>>>>>>>>>>> 1
readline:(T23,NT23)#			Read the next input line
IF(LINID!=1) BREAK#			Exit if not an ATOM line
.........
incrqx:(M,I+ISTEPA,XX0475)#		Request memory for atom
..........
QX(I+5)=BUFIN(3)#			Store x-coordinate in QX
..........
$)# 					<<<<<<<<<<<<<<<<<<<<<<<<< 1