Page:4SIGHT manual- a computer program for modelling degradation of underground low level waste concrete vaults (IA 4sightmanualcomp5612snyd).pdf/107

31.INITIALIZE SOLUBILITY ARRAY 31. Initialize solubility array.

soLarray is vital to determining the chemical equilibrium of each element. This procedure also initializes the two ION arrays: anion and cation

⟨Global variables 4⟩ $$\equiv$$ int num.cations; int num.anions; SOLARRAY **sol.array; ION *cation; ION *anion;

32. The routine malloc requires stdlib.h. ⟨Include files 3⟩ $$\equiv$$
 * 1) include 

33. ⟨Function declarations 23⟩ $$\equiv$$ void initialize.ion.data (void);

34. Initializing ion and salt array. The data for the ions and salts is in the file ion.db. Must first determine the number of anions and cations, including OH~ and H + and then allocate memory for anion, cation, and soLarray.

void initialize_ion-data {    int i, j, k    FILE *ion.database; /* ion and salt data base */ if ((ion-database = fopen(" ion.db", "rt")) $$\equiv\Lambda$$) { printf ("\n\ERROR: Unable to open ion db \n\n"); exit/(0); }   fscanf (ion.database,"%d %d", &num.cations,&num.anions); ⟨Allocate ion and salt arrays 35⟩ ⟨Input ion data 36⟩ ⟨Input salt data 37⟩ fclose(ion.database); ⟨Zero-out ion and salt data 38⟩ }

35. Allocate memory for all of the arrays.

The total number of cations/anions includes and.

⟨Allocate ion and salt arrays 35⟩ $$\equiv$$ anion = (ION *) malloc(num.anions * sizeof (ION)); cation = (ION *) malloc(num.cations * sizeof (ION)); /* allocate 2-D array */ soLarray = (SOLARRAY **) malloc(num-cations * sizeof (SOLARRAY *)); for (i = 0; < num.cations', i++) { sol array[i] = (SOLARRAY *) malloc(num.amons * sizeof (SOLARRAY)); }

This code is used in section 34.