Adding very large arrays
This is really an algorithms question. For example, consider this loop:

for(ii=0;ii&lt;desval;ii++)/*Evaluate the probability total cutoffs*/
{
    ptot[ii]=array_sum(p,ii);
}


why are you calling array_sum() every time through this loop when the only thing that changes is the addition of one more element?
Why can't this loop be: 

sum= 0;
ptot[0]= 0;
for(ii=1;ii&lt;desval;ii++)/*Evaluate the probability total cutoffs*/
{
    ptot[ii]=(sum+= p[ii - 1]);
}