Seppo Mustonen : Programming Survo in C

6. Space allocation

SURVO 84C modules are usually large model programs and compiled with the /AL option of the Microsoft C compiler. Small modules could also be in small model mode, but the current SURVO 84C libraries support only the large model. In large model programs there are no limitations for the size of code and data except the total memory available. In 16 bit micros we additionally have the limit 64KB for each data item (array). We have the same limitation, too, for the code in each compiland, but this is never a real problem, since one module (if reasonably written) is divided into compilands of much smaller size.
     Within these limitations each module should be written so that space is allocated according to each application separately. This means that all vectors and matrices, etc. should get their dimensions dynamically during the run.
     However, temporary arrays whose sizes depend on the line length of the edit field, are typically dimensioned by using the SURVO 84C system constant LLENGTH and its multiplicities. The current value of LLENGTH is 256 and it implies the maximum line length of the edit field to be 253. Another constant is LNAME (current value 64) which is used for names of files (pathnames) etc.
     In some cases the maximum number of columns (or maximum number of words or numbers on a single edit line) is critical for some arrays. The system constant EP4 (current value 100) gives that limit. The counterpart of EP4 in the SURVO.APU file is the system parameter ep4 which may be used in dynamic space allocation for arrays related to number of columns in the edit field.

Matrices should always be defined as one-dimensional arrays and their elements should be saved columnwise. Thus the element on row i and column j of a m*n matrix A will be A[i+n*j] where i=0,1,...,m-1 and j=0,1,...,n-1. In all arrays the base value for the indices is 0. In output, however, the base value is always 1.
     Since double precision should normally used in matrix computations, the largest square matrix (within the 64KB limit) is 90*90.
     Some of the library functions make their own space reservations. For example, when a data set (SURVO_DATA) is opened by the data_open function, memory is allocated for all arrays pointed to by members of this structure.


Previous: Shadow lines
Next: Include files


Front page of Programming Survo in C