Index: /issm/trunk-jpl/src/c/solutions/controltao_core.cpp
===================================================================
--- /issm/trunk-jpl/src/c/solutions/controltao_core.cpp	(revision 11356)
+++ /issm/trunk-jpl/src/c/solutions/controltao_core.cpp	(revision 11357)
@@ -26,7 +26,9 @@
 	/*TAO*/
 	int        ierr;
-	int        num_controls;
+	int        num_controls,solution_type;
+	int        nsteps,maxiter;
 	AppCtx     user;
 	TaoSolver  tao;
+	int       *dummy          = NULL;
 	int       *control_list   = NULL;
 	Vec        X              = NULL;
@@ -41,6 +43,10 @@
 
 	/*Recover some parameters*/
+	femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
 	femmodel->parameters->FindParam(&num_controls,InversionNumControlParametersEnum);
 	femmodel->parameters->FindParam(&control_list,NULL,InversionControlParametersEnum);
+	femmodel->parameters->FindParam(&nsteps,InversionNstepsEnum);
+	femmodel->parameters->FindParam(&dummy,NULL,NULL,InversionMaxiterPerStepEnum);
+	maxiter=nsteps*dummy[0]; xfree((void**)&dummy);
 
 	/*Initialize TAO*/
@@ -54,6 +60,6 @@
 
 	/*Prepare all TAO parameters*/
-	TaoSetMaximumFunctionEvaluations(tao,50);
-	TaoSetMaximumIterations(tao,10);
+	TaoSetMaximumFunctionEvaluations(tao,maxiter);
+	TaoSetMaximumIterations(tao,nsteps);
 	TaoSetTolerances(tao,0.,0.,0.,0.,0.);
 
@@ -78,4 +84,11 @@
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_list[i]);
 	}
+
+	/*Finalize*/
+	_printf_(VerboseControl(),"%s\n","   preparing final solution");
+	femmodel->parameters->SetParam(false,InversionIscontrolEnum); //needed to turn control result output in solutioncore
+	void (*solutioncore)(FemModel*)=NULL;
+	CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);
+	solutioncore(femmodel);
 
 	/*Clean up and return*/
@@ -119,5 +132,4 @@
 	/*Compute objective function*/
 	CostFunctionx(fcn,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
-	_printf_(true,"f(x)=%g\n",*fcn);
 
 	/*Compute gradient*/
@@ -125,5 +137,4 @@
 	VecCopy(gradient,G); VecFree(&gradient);
 	VecScale(G,-1.);
-	//VecView(G,PETSC_VIEWER_STDOUT_WORLD);
 
 	/*Clean-up and return*/
