Index: trunk/psLib/src/dataManip/psMinimize.c
===================================================================
--- trunk/psLib/src/dataManip/psMinimize.c	(revision 1093)
+++ trunk/psLib/src/dataManip/psMinimize.c	(revision 1103)
@@ -37,4 +37,5 @@
 }
 psModelData;
+
 // The first argument to evalModel() and
 // d_evalModel() specifies the data point.
@@ -77,4 +78,5 @@
                    gsl_vector *f)
 {
+    return 0;
     int i;    // Loop index variable.
     int j;    // Loop index variable.
@@ -148,5 +150,11 @@
     // have those parameters removed.  Here will create a new parameter list
     // with the masked parameters added (we expand initialGuess).
+
+    psMemCheckCorruption(1);
+    printf("Calling psVectorAlloc(%d)\n", initialGuess->n);
+
     inputParameterList = psVectorAlloc(initialGuess->n, PS_TYPE_F32);
+    printf("Called psVectorAlloc(%d)\n", initialGuess->n);
+
     if (mask != NULL) {
         j = 0;
@@ -208,14 +216,11 @@
 
     int numData = domain->numCols; // Number of data points
-    gsl_multifit_fdfsolver *s = NULL; // GSL data structure.
     int status;    // Return status for the GSL solver.
     int i = 0;    // Loop index variable.
     int j = 0;    // Loop index variable.
     int iter = 0;   // Iteration counter.
-    psModelData *inputData = NULL; // Contains data that the user-supplied
-    // function/derivate need.
     gsl_multifit_function_fdf f; // GSL structure that contains the
     // functions/derivative to be solved.
-    double *xInit = NULL;  // The initial guess at the parameters
+    double *xInit = NULL;     // The initial guess at the parameters
     // with masked parameters removed.
     const gsl_multifit_fdfsolver_type *T = gsl_multifit_fdfsolver_lmsder;
@@ -223,25 +228,21 @@
     // Marquardt algorithm for chi2
     // minimization.
-
-    inputData = (psModelData *) psAlloc(sizeof(psModelData));
-    inputData->n = numData;
-    inputData->count = 0;
-    inputData->initialGuess = initialGuess;
-    inputData->domain = domain;
-    //    inputData->data = data;
-    //    inputData->errors = errors;
-    //    inputData->paramMask = paramMask;
-    //    inputData->evalModel = evalModel;
-    //    inputData->d_evalModel = DevalModel;
-
-    inputData->count = 0;
+    gsl_multifit_fdfsolver *s; // GSL data structure.
+
+    //    inputData = (psModelData *) psAlloc(sizeof(psModelData));
+    psModelData inputData;
+    inputData.n = numData;
+    inputData.count = 0;
+    inputData.initialGuess = initialGuess;
+    inputData.domain = domain;
+    inputData.count = 0;
     if (paramMask != NULL) {
         for (i=0;i<paramMask->n;i++) {
             if (paramMask->data.U8[i] != 0) {
-                inputData->count++;
+                inputData.count++;
             }
         }
     } else {
-        inputData->count= initialGuess->n;
+        inputData.count= initialGuess->n;
     }
 
@@ -250,20 +251,17 @@
     // parameters are masked out.
 
-    xInit = (double *) psAlloc(inputData->count * sizeof(double));
+    xInit = (double *) psAlloc(inputData.count * sizeof(double));
     if (paramMask != NULL) {
         j = 0;
         for (i=0;i<initialGuess->n;i++) {
             if (paramMask->data.U8[i] == 0) {
-                xInit[j++] = initialGuess->data.F32[i];
+                xInit[j++] = (double) initialGuess->data.F32[i];
             }
         }
     } else {
         for (i=0;i<initialGuess->n;i++) {
-            xInit[i] = initialGuess->data.F32[i];
-        }
-    }
-
-    // Creates the vector for x which GSL uses.  Must deallocate.
-    gsl_vector_view x = gsl_vector_view_array(xInit, inputData->count);
+            xInit[i] = (double) initialGuess->data.F32[i];
+        }
+    }
 
     const gsl_rng_type *type;
@@ -283,11 +281,17 @@
     f.fdf = &gsl_my_function_fdf;
     f.n = numData;
-    f.p = inputData->count;
+    f.p = inputData.count;
     f.params = &inputData;
 
+    printf("inputData.count is %d\n", inputData.count);
+    printf("numData is %d\n", numData);
+    // Creates the vector for x which GSL uses.  Must deallocate.
+    gsl_vector_view x = gsl_vector_view_array(xInit, inputData.count);
+
     // Create an instance of the GSL solver that we will be iterating on.
-    // It will have numData data points and inputData->count parameters.
-    s = gsl_multifit_fdfsolver_alloc(T, numData, inputData->count);
-
+    // It will have numData data points and inputData.count parameters.
+    s = gsl_multifit_fdfsolver_alloc(T, numData, inputData.count);
+
+    printf("HERE 04\n");
     // Initialize the GSL minimizer to use function defined by the data
     // structure "f" and x.vector as an initial guess for the parameters.
@@ -295,4 +299,5 @@
 
 
+    printf("HERE 05\n");
     // Each iteration of the following loop will perform one step in an
     // attempt to minimized chi-squared for the function.  The loop exits
@@ -302,14 +307,19 @@
         iter++;
         // Perform an iteration of the GSL solver.
+        printf("HERE 06\n");
         status = gsl_multifit_fdfsolver_iterate(s);
-
+        printf("HERE 07\n");
         // If there was a problem, abort.
         if (status) {
+            exit(1);
             psAbort(__func__, "gsl_multifit_fdfsolver_iterate()\n");
         }
+        printf("HERE 08\n");
 
         // Test if the parameters changed by a small enough amount.
         status = gsl_multifit_test_delta(s->dx, s->x, 1e-4, 1e-4);
+        printf("HERE 09\n");
     } while (status == GSL_CONTINUE && iter < MAX_LMM_NUM_ITERATIONS);
+    printf("HERE 12\n");
 
 
@@ -339,5 +349,4 @@
     gsl_multifit_fdfsolver_free(s);
     psFree(xInit);
-    psFree(inputData);
 
     // Bye bye.
@@ -621,2 +630,8 @@
     return(NULL);
 }
+
+
+
+
+
+
