Index: issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp
===================================================================
--- issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp	(revision 27716)
+++ issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp	(revision 27717)
@@ -209,5 +209,5 @@
 				if(iomodel->domaintype!=Domain2DhorizontalEnum && !element->IsOnBase()) continue;
 				for(int kk=0;kk<K;kk++){
-					element->DatasetInputAdd(BasalforcingsIsmip6TfEnum,array3d[kk],inputs,iomodel,Ms[kk],Ns[kk],1,BasalforcingsIsmip6TfEnum,7,kk);
+					element->DatasetInputAdd(BasalforcingsIsmip6TfEnum,array3d[kk],inputs,iomodel,Ms[kk],Ns[kk],1,BasalforcingsIsmip6TfEnum,kk);
 				}
 			}
Index: issm/trunk-jpl/src/c/classes/Elements/Element.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 27716)
+++ issm/trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 27717)
@@ -2147,10 +2147,9 @@
 	else _error_("not currently supported type of M and N attempted");
 }/*}}}*/
-void       Element::DatasetInputAdd(int enum_type,IssmDouble* vector,Inputs* inputs,IoModel* iomodel,int M,int N,int vector_type,int input_enum,int code,int input_id){/*{{{*/
+void       Element::DatasetInputAdd(int enum_type,IssmDouble* vector,Inputs* inputs,IoModel* iomodel,int M,int N,int vector_type,int input_enum,int input_id){/*{{{*/
 	/*enum_type: the name of the DatasetInput (eg Outputdefinition1)
 	 * vector: information being stored (eg observations)
 	 * vector_type: is if by element or by vertex
 	 * input_enum: is the name of the vector being stored
-	 * code: what type of data is in the vector (booleans, ints, doubles)
 	 */
 
@@ -2211,35 +2210,8 @@
 		/*Are we in transient or static? */
 		if(M==iomodel->numberofelements){
-			if (code==5){ //boolean
-				_error_("not implemented");
-				//datasetinput->AddInput(new BoolInput(input_enum,reCast<bool>(vector[this->Sid()])),input_id);
-			}
-			else if (code==6){ //integer
-				_error_("not implemented");
-				//datasetinput->AddInput(new IntInput(input_enum,reCast<int>(vector[this->Sid()])),input_id);
-			}
-			else if (code==7){ //IssmDouble
-				_error_("not implemented");
-				//datasetinput->AddInput(new DoubleInput(input_enum,vector[this->Sid()]),input_id);
-			}
-			else _error_("could not recognize nature of vector from code " << code);
+			_error_("not implemented");
 		}
 		else if(M==iomodel->numberofelements+1){
 			_error_("not supported");
-			///*create transient input: */
-			//IssmDouble* times = xNew<IssmDouble>(N);
-			//for(t=0;t<N;t++) times[t] = vector[(M-1)*N+t];
-			//TransientInput* transientinput=new TransientInput(input_enum,times,N);
-			//TriaInput* bof=NULL;
-			//for(t=0;t<N;t++){
-			//	value=vector[N*this->Sid()+t];
-			//	switch(this->ObjectEnum()){
-			//		case TriaEnum:  transientinput->AddTimeInput(new TriaInput( input_enum,&value,P0Enum)); break;
-			//		case PentaEnum: transientinput->AddTimeInput(new PentaInput(input_enum,&value,P0Enum)); break;
-			//		case TetraEnum: transientinput->AddTimeInput(new TetraInput(input_enum,&value,P0Enum)); break;
-			//		default: _error_("Not implemented yet");
-			//	}
-			//}
-			//xDelete<IssmDouble>(times);
 		}
 		else _error_("element vector is either numberofelements or numberofelements+1 long. Field provided (" << EnumToStringx(input_enum) << ") is " << M << " long");
Index: issm/trunk-jpl/src/c/classes/Elements/Element.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 27716)
+++ issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 27717)
@@ -140,5 +140,5 @@
 		void               InputCreateP1FromConstant(Inputs* inputs,IoModel* iomodel,IssmDouble value,int vector_enum);
 		void               ControlInputCreate(IssmDouble* doublearray,IssmDouble* independents_min,IssmDouble* independents_max,Inputs*inputs,IoModel* iomodel,int M,int N,IssmDouble scale,int input_enum,int id);
-		void					 DatasetInputAdd(int enum_type,IssmDouble* vector,Inputs* inputs,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code,int input_enum);
+		void					 DatasetInputAdd(int enum_type,IssmDouble* vector,Inputs* inputs,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int input_enum);
 		void               InputUpdateFromConstant(IssmDouble constant, int name);
 		void               InputUpdateFromConstant(int constant, int name);
Index: issm/trunk-jpl/src/c/classes/IoModel.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 27716)
+++ issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 27717)
@@ -2592,5 +2592,7 @@
 		xDelete<int>(ndims);
 	}
-	*pnumrecords=num_instances;
+	if(pnumrecords){
+		*pnumrecords=num_instances;
+	}
 }
 /*}}}*/
Index: issm/trunk-jpl/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp	(revision 27716)
+++ issm/trunk-jpl/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp	(revision 27717)
@@ -85,5 +85,5 @@
 		for(Object* & object : elements->objects){
 			Element* element=xDynamicCast<Element*>(object);
-			element->DatasetInputAdd(InversionCostFunctionsCoefficientsEnum,&weights[i*iomodel->numberofvertices],inputs,iomodel,M,1,1,cost_function,7,cost_function);
+			element->DatasetInputAdd(InversionCostFunctionsCoefficientsEnum,&weights[i*iomodel->numberofvertices],inputs,iomodel,M,1,1,cost_function,cost_function);
 		}
 	}
Index: issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp	(revision 27716)
+++ issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp	(revision 27717)
@@ -210,6 +210,6 @@
 					for(Object* & object : elements->objects){
 						Element* element=xDynamicCast<Element*>(object);
-						element->DatasetInputAdd(StringToEnumx(cfsurfacesquare_definitionstring_s[j]),cfsurfacesquare_observation_s[j],inputs,iomodel,cfsurfacesquare_observation_M_s[j],cfsurfacesquare_observation_N_s[j],obs_vector_type,StringToEnumx(cfsurfacesquare_observation_string_s[j]),7,SurfaceObservationEnum);
-						element->DatasetInputAdd(StringToEnumx(cfsurfacesquare_definitionstring_s[j]),cfsurfacesquare_weights_s[j],inputs,iomodel,cfsurfacesquare_weights_M_s[j],cfsurfacesquare_weights_N_s[j],weight_vector_type,StringToEnumx(cfsurfacesquare_weights_string_s[j]),7,WeightsSurfaceObservationEnum);
+						element->DatasetInputAdd(StringToEnumx(cfsurfacesquare_definitionstring_s[j]),cfsurfacesquare_observation_s[j],inputs,iomodel,cfsurfacesquare_observation_M_s[j],cfsurfacesquare_observation_N_s[j],obs_vector_type,StringToEnumx(cfsurfacesquare_observation_string_s[j]),SurfaceObservationEnum);
+						element->DatasetInputAdd(StringToEnumx(cfsurfacesquare_definitionstring_s[j]),cfsurfacesquare_weights_s[j],inputs,iomodel,cfsurfacesquare_weights_M_s[j],cfsurfacesquare_weights_N_s[j],weight_vector_type,StringToEnumx(cfsurfacesquare_weights_string_s[j]),WeightsSurfaceObservationEnum);
 
 					}
@@ -260,7 +260,4 @@
 				int         *cfssqt_weights_N_s           = NULL;
 				char       **cfssqt_weights_string_s      = NULL;
-				IssmDouble **cfssqt_datatimes_s           = NULL;
-            int         *cfssqt_datatimes_M_s         = NULL;
-            int         *cfssqt_datatimes_N_s         = NULL;
 
 				/*Fetch name, model_string, observation, observation_string, etc ... (see src/m/classes/cfsurfacesquaretransient.m): */
@@ -268,28 +265,29 @@
 				iomodel->FetchMultipleData(&cfssqt_definitionstring_s,&test,"md.cfsurfacesquaretransient.definitionstring"); _assert_(test==num_cfsurfacesquaretransients);
 				iomodel->FetchMultipleData(&cfssqt_model_string_s,&test,"md.cfsurfacesquaretransient.model_string"); _assert_(test==num_cfsurfacesquaretransients);
-				iomodel->FetchMultipleData(&cfssqt_observations_s,&cfssqt_observations_M_s,&cfssqt_observations_N_s,NULL, "md.cfsurfacesquaretransient.observations");
-				iomodel->FetchMultipleData(&cfssqt_observations_string_s, NULL,"md.cfsurfacesquaretransient.observation_string");
-				iomodel->FetchMultipleData(&cfssqt_weights_s,&cfssqt_weights_M_s,&cfssqt_weights_N_s,NULL,"md.cfsurfacesquaretransient.weights");
-				iomodel->FetchMultipleData(&cfssqt_weights_string_s,NULL,"md.cfsurfacesquaretransient.weights_string");
-				iomodel->FetchMultipleData(&cfssqt_datatimes_s,&cfssqt_datatimes_M_s,&cfssqt_datatimes_N_s,NULL,"md.cfsurfacesquaretransient.datatimes"); 
+				iomodel->FetchMultipleData(&cfssqt_observations_s,&cfssqt_observations_M_s,&cfssqt_observations_N_s,&test, "md.cfsurfacesquaretransient.observations"); _assert_(test==num_cfsurfacesquaretransients);
+				iomodel->FetchMultipleData(&cfssqt_observations_string_s, &test,"md.cfsurfacesquaretransient.observations_string"); _assert_(test==num_cfsurfacesquaretransients);
+				iomodel->FetchMultipleData(&cfssqt_weights_s,&cfssqt_weights_M_s,&cfssqt_weights_N_s, &test,"md.cfsurfacesquaretransient.weights"); _assert_(test==num_cfsurfacesquaretransients);
+				iomodel->FetchMultipleData(&cfssqt_weights_string_s,&test,"md.cfsurfacesquaretransient.weights_string"); _assert_(test==num_cfsurfacesquaretransients);
 
 				for(j=0;j<num_cfsurfacesquaretransients;j++){
 
                /*Check that we can use P1 inputs*/
-					if (cfssqt_observations_M_s[j]==iomodel->numberofvertices) _error_("only P1 fields are allowed for now");
-               if (cfssqt_observations_M_s[j]==cfssqt_weights_M_s[j]) _error_("observations and weights do not have the same number of rows");
-               if (cfssqt_observations_N_s[j]==cfssqt_weights_N_s[j]) _error_("observations and weights do not have the same number of columns");
-               if (cfssqt_datatimes_M_s[j]==1) _error_("datatime should have only one row");
-               if (cfssqt_datatimes_N_s[j]==cfssqt_weights_N_s[j]) _error_("datatime should have the same number of columns as the observations");
+					if (cfssqt_observations_M_s[j]!=(iomodel->numberofvertices+1)) _error_("observations should be a P1 time series");
+               if (cfssqt_weights_M_s[j]!=iomodel->numberofvertices+1)        _error_("weights should be a P1 time series");
+					_assert_(cfssqt_observations_N_s[j]>0);
+
+					/*extract data times from last row of observations*/
+					IssmDouble *datatimes = xNew<IssmDouble>(cfssqt_observations_N_s[j]);
+					for(int k=0;k<cfssqt_observations_N_s[j];k++) datatimes[k] = (cfssqt_observations_s[j])[cfssqt_observations_N_s[j]*(cfssqt_weights_M_s[j]-1)+k];
 
 					/*First create a cfsurfacesquaretransient object for that specific string (cfssqt_model_string_s[j]):*/
-					output_definitions->AddObject(new Cfsurfacesquaretransient(cfssqt_name_s[j], StringToEnumx(cfssqt_definitionstring_s[j]), StringToEnumx(cfssqt_model_string_s[j]), cfssqt_datatimes_N_s[j], cfssqt_datatimes_s[j]));
+					output_definitions->AddObject(new Cfsurfacesquaretransient(cfssqt_name_s[j], StringToEnumx(cfssqt_definitionstring_s[j]), StringToEnumx(cfssqt_model_string_s[j]), cfssqt_observations_N_s[j],datatimes ));
+					xDelete<IssmDouble>(datatimes);
 
 					/*Now, for this particular cfsurfacesquaretransient object, make sure we plug into the elements: the observation, and the weights.*/
 					for(Object* & object : elements->objects){
 						Element* element=xDynamicCast<Element*>(object);
-						_error_("need to implement transient inputs?");
-						//element->DatasetInputAdd(StringToEnumx(cfssqt_definitionstring_s[j]),cfssqt_observations_s[j],inputs,iomodel,cfssqt_observations_M_s[j],cfssqt_observations_N_s[j],obs_vector_type,StringToEnumx(cfssqt_observations_string_s[j]),7,SurfaceObservationEnum);
-						//element->DatasetInputAdd(StringToEnumx(cfssqt_definitionstring_s[j]),cfssqt_weights_s[j],inputs,iomodel,cfssqt_weights_M_s[j],cfssqt_weights_N_s[j],weight_vector_type,StringToEnumx(cfssqt_weights_string_s[j]),7,WeightsSurfaceObservationEnum);
+						element->DatasetInputAdd(StringToEnumx(cfssqt_definitionstring_s[j]),cfssqt_observations_s[j],inputs,iomodel,cfssqt_observations_M_s[j],cfssqt_observations_N_s[j],1,StringToEnumx(cfssqt_observations_string_s[j]),SurfaceObservationEnum);
+						element->DatasetInputAdd(StringToEnumx(cfssqt_definitionstring_s[j]),cfssqt_weights_s[j],inputs,iomodel,cfssqt_weights_M_s[j],cfssqt_weights_N_s[j],1,StringToEnumx(cfssqt_weights_string_s[j]),WeightsSurfaceObservationEnum);
 
 					}
@@ -320,5 +318,4 @@
 				xDelete<int>(cfssqt_weights_N_s);
 				xDelete<char*>(cfssqt_weights_string_s);
-				xDelete<IssmDouble>(cfssqt_datatimes_s);
 				/*}}}*/
 			}
@@ -361,5 +358,5 @@
 						Element* element=xDynamicCast<Element*>(object);
 
-						element->DatasetInputAdd(StringToEnumx(cfdragcoeffabsgrad_definitionstring_s[j]),cfdragcoeffabsgrad_weights_s[j],inputs,iomodel,cfdragcoeffabsgrad_weights_M_s[j],cfdragcoeffabsgrad_weights_N_s[j],weight_vector_type,StringToEnumx(cfdragcoeffabsgrad_weights_string_s[j]),7,WeightsSurfaceObservationEnum);
+						element->DatasetInputAdd(StringToEnumx(cfdragcoeffabsgrad_definitionstring_s[j]),cfdragcoeffabsgrad_weights_s[j],inputs,iomodel,cfdragcoeffabsgrad_weights_M_s[j],cfdragcoeffabsgrad_weights_N_s[j],weight_vector_type,StringToEnumx(cfdragcoeffabsgrad_weights_string_s[j]),WeightsSurfaceObservationEnum);
 
 					}
@@ -423,5 +420,5 @@
 						Element* element=xDynamicCast<Element*>(object);
 
-						element->DatasetInputAdd(StringToEnumx(cfrheologybbarabsgrad_definitionstring_s[j]),cfrheologybbarabsgrad_weights_s[j],inputs,iomodel,cfrheologybbarabsgrad_weights_M_s[j],cfrheologybbarabsgrad_weights_N_s[j],weight_vector_type,StringToEnumx(cfrheologybbarabsgrad_weights_string_s[j]),7,WeightsSurfaceObservationEnum);
+						element->DatasetInputAdd(StringToEnumx(cfrheologybbarabsgrad_definitionstring_s[j]),cfrheologybbarabsgrad_weights_s[j],inputs,iomodel,cfrheologybbarabsgrad_weights_M_s[j],cfrheologybbarabsgrad_weights_N_s[j],weight_vector_type,StringToEnumx(cfrheologybbarabsgrad_weights_string_s[j]),WeightsSurfaceObservationEnum);
 
 					}
@@ -506,7 +503,7 @@
 						Element* element=xDynamicCast<Element*>(object);
 
-						element->DatasetInputAdd(StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_vxobs[j],inputs,iomodel,cfsurfacelogvel_observation_M[j],cfsurfacelogvel_observation_N[j],obs_vector_type,StringToEnumx(cfsurfacelogvel_vxobs_string[j]),7,VxObsEnum);
-							element->DatasetInputAdd(StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_vyobs[j],inputs,iomodel,cfsurfacelogvel_observation_M[j],cfsurfacelogvel_observation_N[j],obs_vector_type,StringToEnumx(cfsurfacelogvel_vyobs_string[j]),7,VyObsEnum);
-						element->DatasetInputAdd(StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_weights[j],inputs,iomodel,cfsurfacelogvel_weights_M[j],cfsurfacelogvel_weights_N[j],weight_vector_type,StringToEnumx(cfsurfacelogvel_weightstring[j]),7,WeightsSurfaceObservationEnum);
+						element->DatasetInputAdd(StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_vxobs[j],inputs,iomodel,cfsurfacelogvel_observation_M[j],cfsurfacelogvel_observation_N[j],obs_vector_type,StringToEnumx(cfsurfacelogvel_vxobs_string[j]),VxObsEnum);
+							element->DatasetInputAdd(StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_vyobs[j],inputs,iomodel,cfsurfacelogvel_observation_M[j],cfsurfacelogvel_observation_N[j],obs_vector_type,StringToEnumx(cfsurfacelogvel_vyobs_string[j]),VyObsEnum);
+						element->DatasetInputAdd(StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_weights[j],inputs,iomodel,cfsurfacelogvel_weights_M[j],cfsurfacelogvel_weights_N[j],weight_vector_type,StringToEnumx(cfsurfacelogvel_weightstring[j]),WeightsSurfaceObservationEnum);
 
 					}
@@ -598,6 +595,6 @@
 					for(Object* & object : elements->objects){
 						Element* element=xDynamicCast<Element*>(object);
-						element->DatasetInputAdd(StringToEnumx(cflevelsetmisfit_definitionstring_s[j]),cflevelsetmisfit_observation_s[j],inputs,iomodel,cflevelsetmisfit_observation_M_s[j],cflevelsetmisfit_observation_N_s[j],obs_vector_type,StringToEnumx(cflevelsetmisfit_observation_string_s[j]),7,LevelsetObservationEnum);
-						element->DatasetInputAdd(StringToEnumx(cflevelsetmisfit_definitionstring_s[j]),cflevelsetmisfit_weights_s[j],inputs,iomodel,cflevelsetmisfit_weights_M_s[j],cflevelsetmisfit_weights_N_s[j],weight_vector_type,StringToEnumx(cflevelsetmisfit_weights_string_s[j]),7,WeightsLevelsetObservationEnum);
+						element->DatasetInputAdd(StringToEnumx(cflevelsetmisfit_definitionstring_s[j]),cflevelsetmisfit_observation_s[j],inputs,iomodel,cflevelsetmisfit_observation_M_s[j],cflevelsetmisfit_observation_N_s[j],obs_vector_type,StringToEnumx(cflevelsetmisfit_observation_string_s[j]),LevelsetObservationEnum);
+						element->DatasetInputAdd(StringToEnumx(cflevelsetmisfit_definitionstring_s[j]),cflevelsetmisfit_weights_s[j],inputs,iomodel,cflevelsetmisfit_weights_M_s[j],cflevelsetmisfit_weights_N_s[j],weight_vector_type,StringToEnumx(cflevelsetmisfit_weights_string_s[j]),WeightsLevelsetObservationEnum);
 					}
 				}
