Index: /issm/trunk-jpl/src/c/classes/objects/DependentObject.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/DependentObject.cpp	(revision 13426)
+++ /issm/trunk-jpl/src/c/classes/objects/DependentObject.cpp	(revision 13426)
@@ -0,0 +1,96 @@
+/*!\file DependentObject.c
+ * \brief: implementation of the DependentObject object
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "./objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+
+/*DependentObject constructors and destructor*/
+/*FUNCTION DependentObject::DependentObject(){{{*/
+DependentObject::DependentObject(){
+	this->name=NoneEnum;
+	this->type=0;
+}
+/*}}}*/
+/*FUNCTION DependentObject::DependentObject(int in_name, int in_type){{{*/
+DependentObject::DependentObject(int in_name, int in_type){
+
+	this->name=in_name;
+	this->type=in_type;
+	if(in_type!=0 && in_type!=1)_error_("cannot create an DependentObject of type " << in_type);
+	if(in_type==1)_error_("not implemented yet!");
+
+}
+/*}}}*/
+/*FUNCTION DependentObject::~DependentObject() {{{*/
+DependentObject::~DependentObject(){ //destructor
+}
+/*}}}*/
+
+
+/*Object virtual functions definitions:*/
+/*FUNCTION DependentObject::Echo{{{*/
+void DependentObject::Echo(void){
+
+	_printLine_("DependentObject:");
+	_printLine_("   name: " << EnumToStringx(this->name));
+	if(this->type==0)
+		_printLine_("   type: scalar");
+	else if(this->type==1)
+		_printLine_("   type: vertex");
+	else
+		_error_(" unknown type: " << this->type);
+}
+/*}}}*/
+/*FUNCTION DependentObject::DeepEcho{{{*/
+void DependentObject::DeepEcho(void){
+	this->Echo();
+}
+/*}}}*/
+/*FUNCTION DependentObject::Id{{{*/
+int    DependentObject::Id(void){ return -1; }
+/*}}}*/
+/*FUNCTION DependentObject::MyRank{{{*/
+int    DependentObject::MyRank(void){ 
+	extern int my_rank;
+
+	return my_rank; 
+}
+/*}}}*/
+/*FUNCTION DependentObject::ObjectEnum{{{*/
+int DependentObject::ObjectEnum(void){
+
+	return DependentObjectEnum;
+
+}
+/*}}}*/
+/*FUNCTION DependentObject::copy{{{*/
+Object* DependentObject::copy(void) { 
+	return new DependentObject(name,type);
+} /*}}}*/
+
+/*DependentObject methods: */
+/*FUNCTION DependentObject::NumDependents{{{*/
+int  DependentObject::NumDependents(void){
+
+	/*Branch according to the type of variable: */
+	if(type==0){ /*scalar:*/
+		return 1;
+	}
+	else if(type==1){ /* vector:*/
+		_error_("not implemented yet!");
+	}
+	else _error_("should not have a type of " << type);
+}
+/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/objects/DependentObject.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/DependentObject.h	(revision 13426)
+++ /issm/trunk-jpl/src/c/classes/objects/DependentObject.h	(revision 13426)
@@ -0,0 +1,38 @@
+/*!\file: DependentObject.h
+ * \brief prototype for DependentObject.h
+ */ 
+
+#ifndef _DEPENDENTOBJECT_H_
+#define  _DEPENDENTOBJECT_H_
+
+/*{{{*/
+#include "./Object.h"
+#include "../../shared/shared.h"
+/*}}}*/
+
+class DependentObject: public Object{
+	
+	public:
+
+		int name;
+		int type;  /*0: scalar, 1: vertex*/
+		
+		/*DependentObject constructors, destructors {{{*/
+		DependentObject();
+		DependentObject(int name, int type);
+		~DependentObject();
+		/*}}}*/
+		/*Object virtual functions definitions:{{{ */
+		void  Echo();
+		void  DeepEcho();
+		int   Id(); 
+		int   MyRank();
+		int   ObjectEnum();
+		Object* copy(void);
+		/*}}}*/
+
+		/*DependentObject methods: */
+		int  NumDependents(void);
+
+};
+#endif //ifndef _DEPENDENTOBJECT_H_
Index: /issm/trunk-jpl/src/c/classes/objects/IndependentObject.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/IndependentObject.cpp	(revision 13426)
+++ /issm/trunk-jpl/src/c/classes/objects/IndependentObject.cpp	(revision 13426)
@@ -0,0 +1,224 @@
+/*!\file IndependentObject.c
+ * \brief: implementation of the IndependentObject object
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "./objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+#include "../IoModel.h"
+
+/*IndependentObject constructors and destructor*/
+/*FUNCTION IndependentObject::IndependentObject(){{{*/
+IndependentObject::IndependentObject(){
+	this->name=NoneEnum;
+	this->type=0;
+	this->numberofvertices=0;
+}
+/*}}}*/
+/*FUNCTION IndependentObject::IndependentObject(int in_name, int in_type,int in_numberofvertices){{{*/
+IndependentObject::IndependentObject(int in_name, int in_type,int in_numberofvertices){
+
+	this->numberofvertices=0;
+	this->name=in_name;
+	this->type=in_type;
+	if(in_type!=0 && in_type!=1)_error_("cannot create an IndependentObject of type " << in_type);
+	if(this->type==1)this->numberofvertices=in_numberofvertices;
+
+}
+/*}}}*/
+/*FUNCTION IndependentObject::~IndependentObject() {{{*/
+IndependentObject::~IndependentObject(){ //destructor
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION IndependentObject::Echo{{{*/
+void IndependentObject::Echo(void){
+
+	_printLine_("IndependentObject:");
+	_printLine_("   name: " << EnumToStringx(this->name));
+	if(this->type==0)
+		_printLine_("   type: scalar");
+	else if(this->type==1)
+		_printLine_("   type: vertex");
+	else
+		_error_(" unknown type: " << this->type);
+	_printLine_("   numberofvertices: " << this->numberofvertices);
+}
+/*}}}*/
+/*FUNCTION IndependentObject::DeepEcho{{{*/
+void IndependentObject::DeepEcho(void){
+	this->Echo();
+}
+/*}}}*/
+/*FUNCTION IndependentObject::Id{{{*/
+int    IndependentObject::Id(void){ return -1; }
+/*}}}*/
+/*FUNCTION IndependentObject::MyRank{{{*/
+int    IndependentObject::MyRank(void){ 
+	extern int my_rank;
+
+	return my_rank; 
+}
+/*}}}*/
+/*FUNCTION IndependentObject::ObjectEnum{{{*/
+int IndependentObject::ObjectEnum(void){
+
+	return IndependentObjectEnum;
+
+}
+/*}}}*/
+/*FUNCTION IndependentObject::copy{{{*/
+Object* IndependentObject::copy(void) { 
+	return new IndependentObject(name,type,numberofvertices);
+} /*}}}*/
+
+
+/*IndependentObject methods: */
+/*FUNCTION IndependentObject::FetchIndependent{{{*/
+void IndependentObject::FetchIndependent(IoModel* iomodel){
+
+	extern int my_rank;
+	FILE* fid=NULL;
+
+	#ifdef _HAVE_ADOLC_ //cannot come here unless you are running AD mode, from DeclaredIndependents:
+	
+	/*Branch according to the type of variable: */
+	if(type==0){ /*scalar: {{{*/
+
+		/*output: */
+		IssmPDouble  pscalar;
+		IssmDouble   scalar; //same as pscalar, except it's an ADOLC independent variable
+		IssmDouble*  scalar_slot=NULL;
+		int      code;
+
+		/*Set file pointer to beginning of the data: */
+		fid=iomodel->SetFilePointerToData(&code,NULL,name);
+
+		if(code!=3)_error_("expecting a IssmDouble for enum " << EnumToStringx(name));
+
+		/*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */
+		if(my_rank==0){
+			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;
+		
+		#ifdef _HAVE_MPI_
+		MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+		#endif
+
+
+		/*Ok, we are almost done. scalar is now an independent variable. We don't want this variable to be fetched again in the 
+		 *future, which would effectively write over the independency in the ADOLC tape! So we are going to keep track of this 
+		 independent variable inthe iomodel->data[name] data slot. Because this data slot holds double*, we allocate a sizeof(double)
+		 space for it: */
+		scalar_slot=xNew<IssmDouble>(1); *scalar_slot=scalar;
+		
+		iomodel->data[name]=scalar_slot;
+		iomodel->independents[name]=true;
+
+
+	} /*}}}*/
+	else if(type==1){ /* vector: {{{*/
+		
+		FILE* fid=NULL;
+		int M,N;
+		IssmPDouble* buffer=NULL; //a buffer to read the data from disk
+		IssmDouble* matrix=NULL; //our independent variable
+		int code=0;
+		int vector_type=0;
+		
+		/*Set file pointer to beginning of the data: */
+		fid=iomodel->SetFilePointerToData(&code,&vector_type,name);
+		if((code!=5) && (code!=6) && (code!=7))_error_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(name));
+		
+		/*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */
+		/*numberofelements: */
+		if(my_rank==0){  
+			if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
+		}
+		#ifdef _HAVE_MPI_
+		MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
+		#endif
+
+		if(my_rank==0){  
+			if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
+		}
+		#ifdef _HAVE_MPI_
+		MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
+		#endif
+
+		/*Now allocate matrix: */
+		if(M*N){
+			buffer=xNew<IssmPDouble>(M*N);
+			matrix=xNew<IssmDouble>(M*N);
+
+			/*Read matrix on node 0, then broadcast: */
+			if(my_rank==0){  
+				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*/
+			}
+			#ifdef _HAVE_MPI_
+			MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+			#endif
+			
+			xDelete<IssmPDouble>(buffer);
+		}
+		else _error_("cannot declare the independent variable " << EnumToStringx(name) <<  "if it's empty!");
+
+		/*Ok, we are almost done. Matrix is now a independent matrix. We don't want this matrix to be fetched again in the 
+		 *future, which would effectively write over the independency in the ADOLC tape! So we are going to keep track of this 
+		 independent matrix inthe iomodel->data[name] data slot: */
+		iomodel->data[name]=matrix;
+		iomodel->independents[name]=true;
+	}/*}}}*/
+	else _error_("should not have a type of " << type);
+
+	#endif
+}
+/*}}}*/
+/*FUNCTION IndependentObject::NumIndependents{{{*/
+int  IndependentObject::NumIndependents(void){
+
+	/*Branch according to the type of variable: */
+	if(type==0){ /*scalar:*/
+		return 1;
+	}
+	else if(type==1){ /* vector:*/
+		return this->numberofvertices;
+	}
+	else _error_("should not have a type of " << type);
+}
+/*}}}*/
+/*FUNCTION IndependentObject::FillIndependents{{{*/
+void IndependentObject::FillIndependents(IssmDouble** data, IssmDouble* xp){
+
+	int i;
+	
+	/*Branch according to the type of variable: */
+	if(type==0){ /*scalar:*/
+		xp[0]=*(data[name]);
+	}
+	else if(type==1){ /* vector:*/
+		IssmDouble* values=data[name];
+		for(i=0;i<this->numberofvertices;i++){
+			xp[i]=values[i];
+		}
+	}
+	else _error_("should not have a type of " << type);
+}
+/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/objects/IndependentObject.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/IndependentObject.h	(revision 13426)
+++ /issm/trunk-jpl/src/c/classes/objects/IndependentObject.h	(revision 13426)
@@ -0,0 +1,43 @@
+/*!\file: IndependentObject.h
+ * \brief prototype for IndependentObject.h
+ */ 
+
+#ifndef _INDEPENDENTOBJECT_H_
+#define  _INDEPENDENTOBJECT_H_
+
+
+/*{{{*/
+#include "./Object.h"
+#include "../../shared/shared.h"
+/*}}}*/
+class IoModel;
+
+class IndependentObject: public Object{
+	
+	public:
+
+		int name;
+		int type;  /*0: scalar, 1: vertex*/
+		int numberofvertices;
+		
+		/*IndependentObject constructors, destructors {{{*/
+		IndependentObject();
+		IndependentObject(int name, int type, int numberofvertices);
+		~IndependentObject();
+		/*}}}*/
+		/*Object virtual functions definitions:{{{ */
+		void  Echo();
+		void  DeepEcho();
+		int   Id(); 
+		int   MyRank();
+		int   ObjectEnum();
+		Object* copy(void);
+		/*}}}*/
+		/*IndependentObject methods: {{{*/
+		void FetchIndependent(IoModel* iomodel);
+		int  NumIndependents(void);
+		void FillIndependents(IssmDouble** data, IssmDouble* xp);
+		/*}}}*/
+
+};
+#endif //ifndef _INDEPENDENTOBJECT_H_
Index: /issm/trunk-jpl/src/c/classes/objects/objects.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/objects.h	(revision 13425)
+++ /issm/trunk-jpl/src/c/classes/objects/objects.h	(revision 13426)
@@ -13,4 +13,6 @@
 #include "./Vertex.h"
 #include "./Node.h"
+#include "./DependentObject.h"
+#include "./IndependentObject.h"
 #include "./Segment.h"
 
@@ -119,4 +121,5 @@
 #include "./Params/StringParam.h"
 #include "./Params/TransientParam.h"
+#include "./Params/DataSetParam.h"
 
 #endif
