Index: /issm/trunk-jpl/src/c/classes/FemModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 20934)
+++ /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 20935)
@@ -365,4 +365,54 @@
 	/*Clean up*/
 	delete iomodel;
+}/*}}}*/
+void FemModel::InitFromFids(char* rootpath, FILE* IOMODEL, FILE* toolkitsoptionsfid, int in_solution_type, bool trace, IssmPDouble* X){/*{{{*/
+	
+	/*intermediary*/
+	int         i;
+	int         analysis_type;
+	
+
+	/*Initialize internal data: */
+	this->solution_type    = in_solution_type;
+	this->analysis_counter = nummodels-1;   //point to last analysis_type carried out.
+	this->results          = new Results(); //not initialized by CreateDataSets
+	
+	/*create IoModel */
+	IoModel* iomodel = new IoModel(IOMODEL,in_solution_type,trace,X);
+
+	/*Figure out what analyses are activated for this solution*/
+	SolutionAnalysesList(&this->analysis_type_list,&this->nummodels,iomodel,this->solution_type);
+
+	/*create datasets for all analyses*/
+	ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,iomodel,toolkitsoptionsfid,rootpath,this->solution_type,this->nummodels,this->analysis_type_list);
+
+	/*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
+	for(i=0;i<nummodels;i++){
+
+		if(VerboseMProcessor()) _printf0_("   Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":\n");
+		analysis_type=analysis_type_list[i];
+		this->SetCurrentConfiguration(analysis_type);
+		
+		if(i==0){
+			if(VerboseMProcessor()) _printf0_("      creating vertex PIDs\n");
+			VerticesDofx(vertices,parameters); 
+
+			if(VerboseMProcessor()) _printf0_("      detecting active vertices\n");
+			GetMaskOfIceVerticesLSMx(this);
+		}
+
+		if(VerboseMProcessor()) _printf0_("      resolving node constraints\n");
+		SpcNodesx(nodes,constraints,parameters,analysis_type); 
+
+		if(VerboseMProcessor()) _printf0_("      creating nodal degrees of freedom\n");
+		NodesDofx(nodes,parameters,analysis_type);
+
+		if(VerboseMProcessor()) _printf0_("      configuring element and loads\n");
+		ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
+	}
+
+	/*Clean up*/
+	delete iomodel;
+
 }/*}}}*/
 void FemModel::Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -2650,6 +2700,4 @@
 
 	/*intermediary*/
-	int         i;
-	int         analysis_type;
 	FILE       *IOMODEL = NULL;
 	FILE       *toolkitsoptionsfid = NULL;
@@ -2658,48 +2706,17 @@
 	size_t      outputsize;
 	char       *outputbuffer;
-	const char* rootpath=""; //needed for Dakota runs only, which we won't do here.
+	const char*       rootpath=""; //needed for Dakota runs only, which we won't do here.
 
 	/*recover my_rank:*/
 	my_rank=IssmComm::GetRank();
 
-	/*Initialize internal data: */
-	this->solution_type    = in_solution_type;
-	this->analysis_counter = nummodels-1;   //point to last analysis_type carried out.
-	this->results          = new Results(); //not initialized by CreateDataSets
-	
-	/*Open input file on cpu 0 and create IoModel */
+	/*Open input file descriptor on cpu 0: */
 	if(my_rank==0) IOMODEL = fmemopen((void*)buffer, buffersize, "rb");
-	IoModel* iomodel = new IoModel(IOMODEL,in_solution_type,trace,X);
-
-	/*Figure out what analyses are activated for this solution*/
-	SolutionAnalysesList(&this->analysis_type_list,&this->nummodels,iomodel,this->solution_type);
-
-	/*Open toolkits file: */
+
+	/*Open toolkits file descriptor: */
 	toolkitsoptionsfid=fmemopen((void*)toolkits, strlen(toolkits)+1, "r");
 
-	/*create datasets for all analyses*/
-	ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,iomodel,toolkitsoptionsfid,(char*)rootpath,this->solution_type,this->nummodels,this->analysis_type_list);
-
-	/*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
-	for(i=0;i<nummodels;i++){
-
-		if(VerboseMProcessor()) _printf0_("   Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":\n");
-		analysis_type=analysis_type_list[i];
-		this->SetCurrentConfiguration(analysis_type);
-
-		if(i==0){
-			if(VerboseMProcessor()) _printf0_("      creating vertex PIDs\n");
-			VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
-		}
-
-		if(VerboseMProcessor()) _printf0_("      resolving node constraints\n");
-		SpcNodesx(nodes,constraints,parameters,analysis_type); 
-
-		if(VerboseMProcessor()) _printf0_("      creating nodal degrees of freedom\n");
-		NodesDofx(nodes,parameters,analysis_type);
-
-		if(VerboseMProcessor()) _printf0_("      configuring element and loads\n");
-		ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
-	}
+	/*Now, go create FemModel:*/
+	this->InitFromFids((char*)rootpath,IOMODEL,toolkitsoptionsfid,in_solution_type,trace,X);
 
 	/*Close input file and toolkits file descriptors: */
@@ -2714,6 +2731,4 @@
 	this->parameters->AddObject(new GenericParam<size_t*>(&outputsize,OutputBufferSizePointerEnum));
 
-	/*Clean up*/
-	delete iomodel;
 }/*}}}*/
 #endif
Index: /issm/trunk-jpl/src/c/classes/FemModel.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/FemModel.h	(revision 20934)
+++ /issm/trunk-jpl/src/c/classes/FemModel.h	(revision 20935)
@@ -55,4 +55,5 @@
 		void Echo();
 		void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, char* restartfilename, const int solution_type,bool trace,IssmPDouble* X=NULL);
+		void InitFromFids(char* rootpath, FILE* IOMODEL, FILE* toolkitsoptionsfid, int in_solution_type, bool trace, IssmPDouble* X=NULL);
 		void Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction);
 		void Restart(void);
