next up previous contents
Next: Function: get_cubic Up: GRASP Routines: Template Bank Previous: Function: regenerate_cubic   Contents


Function: read_cubic

int read_cubic(struct cubic_grid *grid, char *infile);
This routine reads a textfile generated by generate_cubic(), stores the data in a variable grid of type struct cubic_grid, and passes this structure back. read_cubic() itself returns 0 after successful completion, or 1 if the data file was absent or corrupt (in which case grid is left unchanged).

Note that memory for the coefficient array grid.coef is allocated in this routine; to free this memory, call free_cubic(grid). Allocating and de-allocating this array requires some care: since grid.coef[i][j][k] is necessarily symmetric in the first two indecies, the pointers grid.coef[i][j] and grid.coef[j][i] have been explicitly set to point to the same memory location, in order to save memory.

The arguments are:

grid: Output. The coefficient array and related data read from the data file.

infile: Input. The name of the data file.

Author: Teviet Creighton, teviet@tapir.caltech.edu



Bruce Allen 2000-11-19