Index: /issm/trunk/src/c/parallel/convergence.cpp
===================================================================
--- /issm/trunk/src/c/parallel/convergence.cpp	(revision 2032)
+++ /issm/trunk/src/c/parallel/convergence.cpp	(revision 2033)
@@ -67,5 +67,12 @@
 	VecNorm(pf,NORM_2,&nF);
 	res=nKUoldF/nF;
-	if (isnan(res)) throw ErrorException(__FUNCT__,exprintf("mechanical equilibrium convergence criterion is NaN! "));
+	if (isnan(res)){
+		PetscSynchronizedPrintf(MPI_COMM_WORLD,"norm nf %lf \n",nF);
+		PetscSynchronizedFlush(MPI_COMM_WORLD);
+
+		PetscSynchronizedPrintf(MPI_COMM_WORLD,"norm kuold %lf \n",nKUoldF);
+		PetscSynchronizedFlush(MPI_COMM_WORLD);
+		throw ErrorException(__FUNCT__,exprintf("mechanical equilibrium convergence criterion is NaN! "));
+	}
 
 	//clean up
@@ -89,4 +96,5 @@
 		VecDuplicate(old_uf,&duf);VecCopy(old_uf,duf); VecAYPX(duf,-1.0,uf);
 		VecNorm(duf,NORM_2,&ndu); VecNorm(old_uf,NORM_2,&nu);
+
 		if (isnan(ndu) || isnan(nu)) throw ErrorException(__FUNCT__,exprintf("convergence criterion is NaN! "));
 
Index: /issm/trunk/src/c/parallel/gradjcompute_core.cpp
===================================================================
--- /issm/trunk/src/c/parallel/gradjcompute_core.cpp	(revision 2032)
+++ /issm/trunk/src/c/parallel/gradjcompute_core.cpp	(revision 2033)
@@ -24,4 +24,5 @@
 	int sub_analysis_type;
 	int numberofnodes;
+	int control_steady;
 	int numberofdofspernode;
 	char* solverstring=NULL;
@@ -54,4 +55,5 @@
 	femmodel->parameters->FindParam((void*)&analysis_type,"analysis_type");
 	femmodel->parameters->FindParam((void*)&sub_analysis_type,"sub_analysis_type");
+	femmodel->parameters->FindParam((void*)&control_steady,"control_steady");
 	femmodel->parameters->FindParam((void*)&numberofnodes,"numberofnodes");
 	femmodel->parameters->FindParam((void*)&numberofdofspernode,"numberofdofspernode");
@@ -95,5 +97,5 @@
 	}
 
-	if(analysis_type==SteadystateAnalysisEnum()){
+	if(control_steady){
 		diagnostic_results=new DataSet(ResultsEnum()); 
 		diagnostic_core(diagnostic_results,model, inputs);
Index: /issm/trunk/src/c/parallel/objectivefunctionC.cpp
===================================================================
--- /issm/trunk/src/c/parallel/objectivefunctionC.cpp	(revision 2032)
+++ /issm/trunk/src/c/parallel/objectivefunctionC.cpp	(revision 2033)
@@ -41,4 +41,5 @@
 	int     analysis_type;
 	int     sub_analysis_type;
+	int     control_steady;
 	Vec     u_g=NULL;
 	Vec     u_g_full=NULL;
@@ -71,4 +72,5 @@
 	femmodel->parameters->FindParam((void*)&analysis_type,"analysis_type");
 	femmodel->parameters->FindParam((void*)&sub_analysis_type,"sub_analysis_type");
+	femmodel->parameters->FindParam((void*)&control_steady,"control_steady");
 	femmodel->parameters->FindParam((void*)&numberofnodes,"numberofnodes");
 	femmodel->parameters->FindParam((void*)&numberofdofspernode,"numberofdofspernode");
@@ -88,8 +90,9 @@
 	inputs->Add(control_type,param_g_copy,1,numberofnodes);
 
-	if (analysis_type==DiagnosticAnalysisEnum()){
+	if (control_steady==0){
 		//Run diagnostic with updated parameters.
 		diagnostic_core_nonlinear(&u_g,NULL,NULL,NULL,femmodel,inputs,DiagnosticAnalysisEnum(),sub_analysis_type);
 		VecToMPISerial(&u_g_double,u_g); VecFree(&u_g);
+		inputs->Add("velocity",u_g_double,numberofdofspernode,numberofnodes);
 	}
 	else{
@@ -102,13 +105,21 @@
 		delete results_steadystate;
 
+		VecToMPISerial(&u_g_double,u_g); VecFree(&u_g);
+		if(!isstokes){
+			inputs->Add("velocity",u_g_double,3,numberofnodes);
+		}
+		else{
+			inputs->Add("velocity",u_g_double,4,numberofnodes);
+		}
 		//extract the correct number of dofs (3 or 4)
-		VecDuplicatePatch(&u_g_full,u_g);VecFree(&u_g);
-		if(!isstokes){
-			xfree((void**)& dofset);dofset=dofsetgen(2,dofs01,3,numberofnodes*3); VecPartition(&u_g, u_g_full, dofset, numberofnodes*2);
-		}
-		VecFree(&u_g_full);
+//		VecDuplicatePatch(&u_g_full,u_g);VecFree(&u_g);
+//		if(!isstokes){
+//			xfree((void**)& dofset);
+//			dofset=dofsetgen(2,dofs01,3,numberofnodes*3); 
+//			VecPartition(&u_g, u_g_full, dofset, numberofnodes*2);
+//		}
+//		VecFree(&u_g_full);
+//		inputs->Add("velocity",u_g_double,numberofdofspernode,numberofnodes);
 	}
-
-	inputs->Add("velocity",u_g_double,numberofdofspernode,numberofnodes);
 
 	//Compute misfit for this velocity field. 
Index: /issm/trunk/src/c/parallel/steadystate.cpp
===================================================================
--- /issm/trunk/src/c/parallel/steadystate.cpp	(revision 2032)
+++ /issm/trunk/src/c/parallel/steadystate.cpp	(revision 2033)
@@ -30,4 +30,6 @@
 	/*Model: */
 	Model* model=NULL;
+	FemModel* fem_dh=NULL;
+	FemModel* fem_ds=NULL;
 
 	/*Results: */
@@ -122,4 +124,11 @@
 		}
 		else{
+			/*change control_steady to 1 to know we are doing steadystate*/
+			fem_dh=model->GetFormulation(DiagnosticAnalysisEnum(),HorizAnalysisEnum());
+			fem_ds=model->GetFormulation(DiagnosticAnalysisEnum(),StokesAnalysisEnum());
+			param=(Param*)fem_dh->parameters->FindParamObject("control_steady");
+			param->SetInteger(1);
+			param=(Param*)fem_ds->parameters->FindParamObject("control_steady");
+			param->SetInteger(1);
 			/*run control analysis: */
 			_printf_("call computational core:\n");
