Index: ../trunk-jpl/src/c/classes/Elements/Element.h
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Element.h	(revision 18883)
+++ ../trunk-jpl/src/c/classes/Elements/Element.h	(revision 18884)
@@ -103,7 +103,7 @@
 		IssmDouble GetXcoord(IssmDouble* xyz_list,Gauss* gauss);
 		IssmDouble GetYcoord(IssmDouble* xyz_list,Gauss* gauss);
 		IssmDouble GetZcoord(IssmDouble* xyz_list,Gauss* gauss);
-		void       GradientIndexing(int* indexing,int control_index);
+		void       GradientIndexing(int* indexing,int control_index,bool onsid=false);
 		bool       HasNodeOnBase();
 		bool       HasNodeOnSurface();
 		int        Id();
@@ -287,7 +287,7 @@
 
 		virtual void   ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index)=0;
 		virtual void   ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum)=0;
-		virtual void   GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data)=0;
+		virtual void   GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data,bool onsid)=0;
 		virtual void   SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index)=0;
 		virtual void   InputControlUpdate(IssmDouble scalar,bool save_parameter)=0;
 
Index: ../trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 18883)
+++ ../trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 18884)
@@ -3033,16 +3033,16 @@
 	vector_gradient->SetValues(NUMVERTICES,&sidlist[0],&gradients[0],ADD_VAL);
 
 }/*}}}*/
-void       Tria::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data){/*{{{*/
+void       Tria::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data,bool onsid){/*{{{*/
 
-	int vertexpidlist[NUMVERTICES];
+	int vertexidlist[NUMVERTICES];
 	Input *input=NULL;
 
 	/*Get out if this is not an element input*/
 	if(!IsInput(control_enum)) return;
 
 	/*Prepare index list*/
-	GradientIndexing(&vertexpidlist[0],control_index);
+	GradientIndexing(&vertexidlist[0],control_index,onsid);
 
 	/*Get input (either in element or material)*/
 	input=(Input*)this->inputs->GetInput(control_enum);   _assert_(input);
@@ -3052,7 +3052,7 @@
 		_error_("input " << EnumToStringx(control_enum) << " is not a ControlInput");
 	}
 
-	((ControlInput*)input)->GetVectorFromInputs(vector,&vertexpidlist[0],data);
+	((ControlInput*)input)->GetVectorFromInputs(vector,&vertexidlist[0],data);
 }
 /*}}}*/
 void       Tria::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){/*{{{*/
Index: ../trunk-jpl/src/c/classes/Elements/Tria.h
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Tria.h	(revision 18883)
+++ ../trunk-jpl/src/c/classes/Elements/Tria.h	(revision 18884)
@@ -131,7 +131,7 @@
 		void   GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y);
 		#endif
 
-		void       GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data);
+		void       GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data,bool onsid);
 		void       SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index);
 		void       ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index);
 		void       ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum);
Index: ../trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 18883)
+++ ../trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 18884)
@@ -3196,15 +3196,15 @@
 	xDelete<int>(control_type);
 }
 /*}}}*/
-void       Penta::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data){/*{{{*/
+void       Penta::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data,bool onsid){/*{{{*/
 
-	int vertexpidlist[NUMVERTICES];
+	int vertexidlist[NUMVERTICES];
 
 	/*Get out if this is not an element input*/
 	if(!IsInput(control_enum)) return;
 
 	/*Prepare index list*/
-	GradientIndexing(&vertexpidlist[0],control_index);
+	GradientIndexing(&vertexidlist[0],control_index,onsid);
 
 	/*Get input (either in element or material)*/
 	if(control_enum==MaterialsRheologyBbarEnum) control_enum=MaterialsRheologyBEnum;
@@ -3216,7 +3216,7 @@
 		_error_("input " << EnumToStringx(control_enum) << " is not a ControlInput");
 	}
 
-	((ControlInput*)input)->GetVectorFromInputs(vector,&vertexpidlist[0],data);
+	((ControlInput*)input)->GetVectorFromInputs(vector,&vertexidlist[0],data);
 }
 /*}}}*/
 void       Penta::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){/*{{{*/
Index: ../trunk-jpl/src/c/classes/Elements/Penta.h
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Penta.h	(revision 18883)
+++ ../trunk-jpl/src/c/classes/Elements/Penta.h	(revision 18884)
@@ -125,7 +125,7 @@
 		void   GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y);
 		#endif
 
-		void   GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data);
+		void   GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data,bool onsid);
 		void   SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index);
 		void   ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index);
 		void   ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum);
Index: ../trunk-jpl/src/c/classes/Elements/Seg.h
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Seg.h	(revision 18883)
+++ ../trunk-jpl/src/c/classes/Elements/Seg.h	(revision 18884)
@@ -163,7 +163,7 @@
 		void   GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y){_error_("not implemented yet");};
 #endif
 
-		void       GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data){_error_("not implemented yet");};
+		void       GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data,bool onsid){_error_("not implemented yet");};
 		void       SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){_error_("not implemented yet");};
 		void       ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){_error_("not implemented yet");};
 		void       ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum){_error_("not implemented yet");};
Index: ../trunk-jpl/src/c/classes/Elements/Tetra.h
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Tetra.h	(revision 18883)
+++ ../trunk-jpl/src/c/classes/Elements/Tetra.h	(revision 18884)
@@ -169,7 +169,7 @@
 
 		IssmDouble DragCoefficientAbsGradient(void){_error_("not implemented yet");};
 		void       GradientIndexing(int* indexing,int control_index){_error_("not implemented yet");};
-		void       GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data){_error_("not implemented yet");};
+		void       GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data,bool onsid){_error_("not implemented yet");};
 		void       SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){_error_("not implemented yet");};
 		void       ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){_error_("not implemented yet");};
 		void       ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum){_error_("not implemented yet");};
Index: ../trunk-jpl/src/c/classes/Elements/Element.cpp
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 18883)
+++ ../trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 18884)
@@ -943,7 +943,7 @@
 	xDelete<IssmDouble>(z_list);
 	return z;
 }/*}}}*/
-void       Element::GradientIndexing(int* indexing,int control_index){/*{{{*/
+void       Element::GradientIndexing(int* indexing,int control_index,bool onsid){/*{{{*/
 
 	/*Get number of controls*/
 	int num_controls;
@@ -953,9 +953,16 @@
 	int numvertices = this->GetNumberOfVertices();
 
 	/*get gradient indices*/
-	for(int i=0;i<numvertices;i++){
-		indexing[i]=num_controls*this->vertices[i]->Pid() + control_index;
+	if(onsid){
+		for(int i=0;i<numvertices;i++){
+			indexing[i]=num_controls*this->vertices[i]->Sid() + control_index;
+		}
 	}
+	else{
+		for(int i=0;i<numvertices;i++){
+			indexing[i]=num_controls*this->vertices[i]->Pid() + control_index;
+		}
+	}
 
 }
 /*}}}*/
