Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 12381)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 12382)
@@ -331,5 +331,14 @@
 					./solvers/solver_linear.cpp\
 					./solvers/solver_nonlinear.cpp\
-					./solvers/solver_newton.cpp
+					./solvers/solver_newton.cpp\
+					./objects/Options/Option.cpp\
+					./objects/Options/Option.h\
+					./objects/Options/OptionDouble.cpp\
+					./objects/Options/OptionDouble.h\
+					./objects/Options/OptionChar.cpp\
+					./objects/Options/OptionChar.h\
+					./objects/Options/OptionUtilities.cpp\
+					./objects/Options/OptionUtilities.h
+
 #}}}
 #DAKOTA sources  {{{1
Index: /issm/trunk-jpl/src/c/objects/IoModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/IoModel.cpp	(revision 12381)
+++ /issm/trunk-jpl/src/c/objects/IoModel.cpp	(revision 12382)
@@ -867,4 +867,55 @@
 }
 /*}}}*/
+/*FUNCTION IoModel::FetchData(Option** poption,int data_enum){{{*/
+void  IoModel::FetchData(Option** poption,int index){
+
+	extern int my_rank;
+	extern int num_procs;
+
+	/*output: */
+	int     code;
+	Option *option      = NULL;
+	char   *name        = NULL;
+
+	/*First get option name*/
+	this->FetchData(&name,index);
+	_printf_(true,"Option name is %s\n",name);
+
+	/*Get option value*/
+	fid=this->SetFilePointerToData(&code,NULL,index+1);
+	switch(code){
+		case 3: {//double
+			  double *value = NULL;
+			  value=(double*)xmalloc(1*sizeof(double));
+			  FetchData(value,index+1);
+			  _printf_(true,"value = %g\n",*value);
+			  option = new OptionDouble();
+			  ((OptionDouble*)option)->values = value;
+			  option->name  = name;
+			  option->numel = 1;
+			  option->ndims = 1;
+			  option->size  = NULL;
+			  break;
+			  }
+		case 4: {//char
+			  char* value = NULL;
+			  FetchData(&value,index+1);
+			  _printf_(true,"value = %s\n",value);
+			  option = new OptionChar();
+			  ((OptionChar*)option)->values = value;
+			  option->name  = name;
+			  option->numel = 1;
+			  option->ndims = 1;
+			  option->size  = NULL;
+			  break;
+			  }
+		default:
+			  _error_("Option of format %i not supported yet",code);
+	}
+
+	/*Assign output pointers: */
+	*poption=option;
+}
+/*}}}*/
 /*FUNCTION IoModel::FetchData(int num,...){{{*/
 void  IoModel::FetchData(int num,...){
@@ -1097,4 +1148,39 @@
 	xfree((void**)&string);
 }
+/*FUNCTION IoModel::LastIndex{{{*/
+void IoModel::LastIndex(int *pindex){
+
+	extern int my_rank;
+	int        lastindex,index;
+	int        record_length;
+
+	/*Go find in the binary file, the position of the data we want to fetch: */
+	if(my_rank==0){
+
+		/*First set FILE* position to the beginning of the file: */
+		fseek(fid,0,SEEK_SET);
+
+		/*Now march through file looking for the correct data identifier: */
+		for(;;){
+			/*Read enum for this size of first string name: */
+			if(fread(&index,sizeof(int),1,fid)==0){
+				/*Ok, we have reached the end of the file. break: */
+				break;
+			}
+
+			/*read the record length, and use it to skip this record: */
+			fread(&record_length,sizeof(int),1,fid);
+			fseek(fid,record_length,SEEK_CUR);
+			lastindex=index;
+		}
+	}
+	/*Broadcast code and vector type: */
+#ifdef _HAVE_MPI_
+	MPI_Bcast(&lastindex,1,MPI_INT,0,MPI_COMM_WORLD); 
+#endif
+
+	/*Assign output pointers:*/
+	*pindex=lastindex;
+}
 /*FUNCTION IoModel::SetFilePointerToData{{{*/
 FILE* IoModel::SetFilePointerToData(int* pcode,int* pvector_type, int data_enum){
@@ -1102,5 +1188,5 @@
 	extern int my_rank;
 	extern int num_procs;
-	
+
 	int found=0;
 	int record_enum;
@@ -1108,8 +1194,8 @@
 	int record_code; //1 to 7 number
 	int vector_type; //nodal or elementary
- 
+
 	/*Go find in the binary file, the position of the data we want to fetch: */
 	if(my_rank==0){
-	
+
 		/*First set FILE* position to the beginning of the file: */
 		fseek(fid,0,SEEK_SET);
@@ -1123,5 +1209,5 @@
 				break;
 			}
-			
+
 			/*Is this the record sought for? : */
 			if (data_enum==record_enum){
@@ -1143,15 +1229,15 @@
 		}
 	}
-	#ifdef _HAVE_MPI_
+#ifdef _HAVE_MPI_
 	MPI_Bcast(&found,1,MPI_INT,0,MPI_COMM_WORLD); 
 	if(!found)_error_("%s %s ","could not find data with name",EnumToStringx(data_enum));
-	#endif
+#endif
 
 	/*Broadcast code and vector type: */
-	#ifdef _HAVE_MPI_
+#ifdef _HAVE_MPI_
 	MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD); 
 	MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD); 
 	if(record_code==5) MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD); 
-	#endif
+#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/objects/IoModel.h
===================================================================
--- /issm/trunk-jpl/src/c/objects/IoModel.h	(revision 12381)
+++ /issm/trunk-jpl/src/c/objects/IoModel.h	(revision 12382)
@@ -13,5 +13,5 @@
 class Elements;
 class Param;
-
+class Option;
 
 class IoModel {
@@ -23,5 +23,5 @@
 	public:
 		/*This data needs to stay memory resident at all time, even if it's memory intensive: */
-		FILE        *fid;         //pointer to input file
+		FILE *fid;         //pointer to input file
 		bool *my_elements;
 		bool *my_nodes;
@@ -41,24 +41,26 @@
 
 		/*Input/Output*/
-		void    CheckEnumSync(void);
-		void    Constant(bool   *poutput,int constant_enum);
-		void    Constant(int    *poutput,int constant_enum);
-		void    Constant(IssmDouble *poutput,int constant_enum);
-		void    Constant(char  **poutput,int constant_enum);
-		Param  *CopyConstantObject(int constant_enum);
+		void        CheckEnumSync(void);
+		void        Constant(bool *poutput,int constant_enum);
+		void        Constant(int *poutput,int constant_enum);
+		void        Constant(IssmDouble *poutput,int constant_enum);
+		void        Constant(char **poutput,int constant_enum);
+		Param      *CopyConstantObject(int constant_enum);
 		IssmDouble *Data(int dataenum);
-		void    DeleteData(int num,...);
-		void    FetchConstants(void);
-		void    FetchData(bool*     pboolean,int data_enum);
-		void    FetchData(int*      pinteger,int data_enum);
-		void    FetchData(IssmDouble*   pscalar,int data_enum);
-		void    FetchData(char**    pstring,int data_enum);
-		void    FetchData(int** pmatrix,int* pM,int* pN,int data_enum);
-		void    FetchData(IssmDouble**  pscalarmatrix,int* pM,int* pN,int data_enum);
-		void    FetchData(char***   pstringarray,int* pnumstrings,int data_enum);
-		void    FetchData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum);
-		void    FetchData(int num,...);
-		void    FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum=NoneEnum,IssmDouble default_value=0);
-		FILE*   SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
+		void        DeleteData(int num,...);
+		void        FetchConstants(void);
+		void        FetchData(bool* pboolean,int data_enum);
+		void        FetchData(int* pinteger,int data_enum);
+		void        FetchData(IssmDouble* pscalar,int data_enum);
+		void        FetchData(char** pstring,int data_enum);
+		void        FetchData(int** pmatrix,int* pM,int* pN,int data_enum);
+		void        FetchData(IssmDouble**  pscalarmatrix,int* pM,int* pN,int data_enum);
+		void        FetchData(char***   pstringarray,int* pnumstrings,int data_enum);
+		void        FetchData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum);
+		void        FetchData(Option **poption,int data_enum);
+		void        FetchData(int num,...);
+		void        FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum=NoneEnum,IssmDouble default_value=0);
+		void        LastIndex(int *pindex);
+		FILE*       SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
 };
 
Index: /issm/trunk-jpl/src/c/solutions/kriging.cpp
===================================================================
--- /issm/trunk-jpl/src/c/solutions/kriging.cpp	(revision 12381)
+++ /issm/trunk-jpl/src/c/solutions/kriging.cpp	(revision 12382)
@@ -136,5 +136,5 @@
 void ProcessInputfile(double **px,double **py,double **pdata,int *pnobs,double **px_interp,double **py_interp,int *pninterp,Options **poptions,FILE* fid){
 
-	int      ninterp,nobs;
+	int      ninterp,nobs,numoptions;
 	double  *x        = NULL;
 	double  *y        = NULL;
@@ -143,4 +143,5 @@
 	double  *y_interp = NULL;
 	Options *options  = NULL;
+	Option  *option   = NULL;
 
 	int dummy,M,N;
@@ -148,102 +149,19 @@
 	iomodel->fid=fid;
 	iomodel->CheckEnumSync();
-
-	/*Read x*/
-	fid=iomodel->SetFilePointerToData(&dummy,&dummy,0);
-	if(my_rank==0){
-		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
-	}
-	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(my_rank==0){  
-		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
-	}
-	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(M*N){
-		x=(double*)xmalloc(M*N*sizeof(double));
-		if(my_rank==0){  
-			if(fread(x,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
-		}
-		MPI_Bcast(x,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
-	}
-	nobs=M*N;
-
-	/*Read y*/
-	fid=iomodel->SetFilePointerToData(&dummy,&dummy,1);
-	if(my_rank==0){  
-		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
-	}
-	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(my_rank==0){  
-		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
-	}
-	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(M*N){
-		y=(double*)xmalloc(M*N*sizeof(double));
-		if(my_rank==0){  
-			if(fread(y,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
-		}
-		MPI_Bcast(y,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
-	}
-	_assert_(M*N==nobs);
-
-	/*Read data*/
-	fid=iomodel->SetFilePointerToData(&dummy,&dummy,2);
-	if(my_rank==0){  
-		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
-	}
-	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(my_rank==0){  
-		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
-	}
-	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(M*N){
-		data=(double*)xmalloc(M*N*sizeof(double));
-		if(my_rank==0){  
-			if(fread(data,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
-		}
-		MPI_Bcast(data,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
-	}
-	_assert_(M*N==nobs);
-
-	/*Read x_interp*/
-	fid=iomodel->SetFilePointerToData(&dummy,&dummy,3);
-	if(my_rank==0){  
-		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
-	}
-	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(my_rank==0){  
-		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
-	}
-	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(M*N){
-		x_interp=(double*)xmalloc(M*N*sizeof(double));
-		if(my_rank==0){  
-			if(fread(x_interp,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
-		}
-		MPI_Bcast(x_interp,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
-	}
-	ninterp=N*M;
-
-	/*Read y_interp*/
-	fid=iomodel->SetFilePointerToData(&dummy,&dummy,4);
-	if(my_rank==0){  
-		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
-	}
-	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(my_rank==0){  
-		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
-	}
-	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(M*N){
-		y_interp=(double*)xmalloc(M*N*sizeof(double));
-		if(my_rank==0){  
-			if(fread(y_interp,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
-		}
-		MPI_Bcast(y_interp,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
-	}
-	_assert_(N*M==ninterp);
+	iomodel->FetchData(&x,&M,&N,0);        nobs=M*N;
+	iomodel->FetchData(&y,&M,&N,1);        _assert_(M*N==nobs);
+	iomodel->FetchData(&data,&M,&N,2);     _assert_(M*N==nobs);
+	iomodel->FetchData(&x_interp,&M,&N,3); ninterp=M*N;
+	iomodel->FetchData(&y_interp,&M,&N,4); _assert_(M*N==ninterp);
 
 	/*Read options*/
 	options = new Options();
+	iomodel->LastIndex(&N);
+	numoptions=(int)((N-4)/2);
+	for(int i=0;i<numoptions;i++){
+		iomodel->FetchData(&option,5+2*i);
+		options->AddOption(option);
+		option=NULL;
+	}
 
 	/*Assign output pointer*/
