Index: /issm/trunk-jpl/src/c/classes/IndependentObject.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/IndependentObject.cpp	(revision 18870)
+++ /issm/trunk-jpl/src/c/classes/IndependentObject.cpp	(revision 18871)
@@ -70,11 +70,15 @@
 
 /*IndependentObject methods: */
-void IndependentObject::FetchIndependent(IoModel* iomodel){/*{{{*/
+void IndependentObject::FetchIndependent(IoModel* iomodel,int* pXcount,IssmPDouble* X){ /*{{{*/
 
 	int my_rank;
 	FILE* fid=NULL;
+	int Xcount;
 
 	/*recover my_rank:*/
 	my_rank=IssmComm::GetRank();
+
+	/*recover Xcount if X is not NULL:*/
+	if(X)Xcount=*pXcount;
 
 	#ifdef _HAVE_ADOLC_ //cannot come here unless you are running AD mode, from DeclaredIndependents:
@@ -98,6 +102,12 @@
 			if(fread(&pscalar,sizeof(IssmPDouble),1,fid)!=1)_error_("could not read scalar ");
 
-			/*Now, before we even broadcast this to other nodes, declare the scalar  as an independent variable!: */
-			scalar<<=pscalar;
+			/*Now, before we even broadcast this to other nodes, declare the scalar  as an independent variable!. If we 
+			 *have been supplied an X vector, use it instead of what we just read: */
+			if(X){
+				scalar<<=X[Xcount];
+			}
+			else{
+				scalar<<=pscalar;
+			}
 		}
 
@@ -113,4 +123,7 @@
 		iomodel->independents[name]=true;
 
+		/*increment offset into X vector, now that we have read 1 value:*/
+		Xcount++; *pXcount=Xcount;
+
 		//finally, record the number of independents:
 		this->numberofindependents=1;
@@ -150,6 +163,12 @@
 				if(fread(buffer,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix ");
 
-				/*Now, before we even broadcast this to other nodes, declare the whole matrix as a independent variable!: */
-				for (int i=0;i<M*N;++i) matrix[i]<<=buffer[i];  /*we use the <<= ADOLC overloaded operator to declare the independency*/
+				/*Now, before we even broadcast this to other nodes, declare the whole matrix as a independent variable!
+				 If we have been supplied an X vector, use it instead of what we just read: */
+				if(X){
+					for (int i=0;i<M*N;++i) matrix[i]<<=X[Xcount+i];  /*we use the <<= ADOLC overloaded operator to declare the independency*/
+				}
+				else{
+					for (int i=0;i<M*N;++i) matrix[i]<<=buffer[i];  /*we use the <<= ADOLC overloaded operator to declare the independency*/
+				}
 			}
 			ISSM_MPI_Bcast(matrix,M*N,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 
@@ -165,4 +184,8 @@
 		iomodel->independents[name]=true;
 
+			
+		/*increment offset into X vector, now that we have read M*N values:*/
+		Xcount+=M*N; *pXcount=Xcount;
+		
 		//Finally, record the number of independents created: 
 		this->numberofindependents=M*N;
