Index: /issm/trunk-jpl/src/c/cores/controlm1qn3_core.cpp
===================================================================
--- /issm/trunk-jpl/src/c/cores/controlm1qn3_core.cpp	(revision 17895)
+++ /issm/trunk-jpl/src/c/cores/controlm1qn3_core.cpp	(revision 17896)
@@ -32,46 +32,37 @@
 
 void controlm1qn3_core(FemModel* femmodel){
+
+	/*Intermediaries*/
+	long   omode; /*m1qn3 output flag*/
+	double f;     /*cost function value*/
+
 	if(VerboseControl())_printf0_("   Initialize M1QN3 parameters\n");
-
-	const int pbdim = 2;
-
-	/*Solution parameters*/
-	double c = 10.;
-
-	/*output*/
-	long omode;
-
-	/*Function evaluation and gradient*/
-	double f;
-	double g[2]; /**/
-
-	/*m1qn3 parameters*/
 	SimulFunc costfuncion  = &simul;    /*Cost function address*/
 	void**    prosca       = &euclid_;  /*Dot product function (euclid is the default)*/
-	char      normtype[3];              /*Norm type: dfn = scalar product defined by prosca*/
-	strcpy(normtype, "dfn");
+	char      normtype[3];              /*Norm type: dfn = scalar product defined by prosca*/ strcpy(normtype, "dfn");
+	double    dzs[1];                   /*Arrays used by m1qn3 subroutines*/
+	long      izs[5];                   /*Arrays used by m1qn3 subroutines*/
+	float     rzs[1];                   /*Arrays used by m1qn3 subroutines*/
 	long      impres       = 0;         /*verbosity level*/
-	long      imode[3]     = {0};
+	long      imode[3]     = {0};       /*scaling and starting mode, 0 by default*/
 	long      indic        = 4;         /*compute f and g*/
-	long      reverse      = 0;
-	long      ndz          = 20000; /*Dimension of the working area*/
-	double    dz[20000];            /*Working array*/
-	long      iz[5];
-	double    dxmin        = 1.e-10; /*Resolution for the solution x*/
-	double    epsrel       = 1.e-5;  /*Gradient stopping criterion in ]0 1[ -> |gk|/|g1| < epsrel*/
-	long      niter        = 200;    /*Maximum number of iterations*/
-	long      nsim         = 200;    /*Maximum number of function calls*/
-	long      io           = 6;      /*Channel number for the output*/
-	/*Arrayes used by m1qn3 subroutines*/
-	double    dzs[1];
-	long      izs[5];
-	float     rzs[1];
+	long      reverse      = 0;         /*reverse or direct mode*/
+	long      ndz          = 20000;     /*Dimension of the working area*/
+	double    dz[20000];                /*Working array*/
+	long      iz[5];                    /*Integer m1qn3 working array of size 5*/
+	long      niter        = 200;       /*Maximum number of iterations*/
+	long      nsim         = 200;       /*Maximum number of function calls*/
+	long      io           = 6;         /*Channel number for the output*/
 
+	/*Optimization criterions*/
+	double    dxmin        = 1.e-10;    /*Resolution for the solution x*/
+	double    epsrel       = 1.e-5;     /*Gradient stopping criterion in ]0 1[ -> |gk|/|g1| < epsrel*/
 
-	/*Prepare initial guess*/
-	long      n = pbdim;
-	double    x[pbdim];
+	/*Get problem dimension and initialize gradient and initial guess*/
+	long    n = 2;
+	double* g = xNew<double>(n);
+	double* x = xNew<double>(n);
 	for(int i=0;i<n;i++) x[i]=5.;
-	dzs[0] = c;
+	dzs[0] = 10; //c = 10 function parameter
 
 	if(VerboseControl())_printf0_("   Computing initial solution\n");
@@ -97,5 +88,9 @@
 
 	_printf0_(" == Final cost function = "<< f <<"\n");
-	_printf0_(" == Final x = ["<<x[0]<<" "<<x[1]<<"]\n");
+	//_printf0_(" == Final x = ["<<x[0]<<" "<<x[1]<<"]\n");
+
+	/*Clean-up and return*/
+	xDelete<double>(g);
+	xDelete<double>(x);
 }
 #else
