Index: /issm/trunk-jpl/src/c/classes/FemModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 13615)
+++ /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 13616)
@@ -75,84 +75,12 @@
 }
 /*}}}*/
-/*FUNCTION FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){{{*/
-void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){
-	
-	/*intermediary*/
-	int         i;
-	int         analysis_type;
-	FILE       *IOMODEL = NULL;
-	FILE       *petscoptionsfid = NULL;
-	FILE       *output_fid = NULL;
-	int         my_rank;
-	
-	/*recover my_rank:*/
-	my_rank=IssmComm::GetRank();
-
-	/*Open input file on cpu 0: */
-	if(my_rank==0) IOMODEL = pfopen(inputfilename ,"rb");
-
-	/*Initialize internal data: */
-	this->nummodels        = nummodels;
-	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
-	
-	/*Dynamically allocate whatever is a list of length nummodels: */
-	analysis_type_list=xNew<int>(nummodels);
-
-	/*Initialize: */
-	for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
-
-	/*create datasets for all analyses*/
-	ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,rootpath,this->solution_type,nummodels,analyses);
-
-	/*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
-	for(i=0;i<nummodels;i++){
-
-		if(VerboseMProcessor()) _pprintLine_("   Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":");
-		analysis_type=analysis_type_list[i];
-		this->SetCurrentConfiguration(analysis_type);
-	
-		if(i==0){
-			if(VerboseMProcessor()) _pprintLine_("      creating vertex degrees of freedom");
-			VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
-		}
-
-		if(VerboseMProcessor()) _pprintLine_("      resolving node constraints");
-		SpcNodesx(nodes,constraints,parameters,analysis_type); 
-
-		if(VerboseMProcessor()) _pprintLine_("      creating nodal degrees of freedom");
-		NodesDofx(nodes,parameters,analysis_type);
-	
-		if(VerboseMProcessor()) _pprintLine_("      configuring element and loads");
-		ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
-	}
-	
-	/*Close input file descriptors: */
-	if(my_rank==0) pfclose(IOMODEL,inputfilename);
-
-	/*Open output file once for all and add output file name and file descriptor to parameters*/
-	output_fid=pfopen(outputfilename,"wb");
-	this->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename));
-	this->parameters->SetParam(output_fid,OutputFilePointerEnum);
-	
-	/*Save lock file name for later: */
-	this->parameters->AddObject(new StringParam(LockFileNameEnum,lockfilename));
-
-	/*Now, deal with petsc options, which need to be put into the parameters dataset: */
-	petscoptionsfid=pfopen(petscfilename,"r");
-	ParsePetscOptionsx(this->parameters,petscoptionsfid);
-	pfclose(petscoptionsfid,petscfilename);
-}
-/*}}}*/
-/*FUNCTION FemModel::destructor {{{*/
+/*FUNCTION FemModel::~FemModel{{{*/
 FemModel::~FemModel(){
 
 	/*Intermediary*/
-	int i;
-	FILE* output_fid;
-	char* outbinfilename=NULL;
-	char* lockfilename=NULL;
-	bool   waitonlock=false;
+	FILE *output_fid;
+	char *outbinfilename = NULL;
+	char *lockfilename   = NULL;
+	bool  waitonlock     = false;
 
 	/*Close output file: */
@@ -201,65 +129,4 @@
 
 /*Object management*/
-/*FUNCTION FemModel::OutputResults {{{*/
-void FemModel::OutputResults(void){
-	
-	_pprintLine_("write results to disk:");
-
-	/*Just call the OutputResultsx module: */
-	OutputResultsx(this->elements, this->nodes, this->vertices, this->loads, this->materials, this->parameters,this->results);
-
-}
-/*}}}*/
-/*FUNCTION FemModel::Solve {{{*/
-void FemModel::Solve(void){
-
-	/*profiling: */
-	bool profiling = false;
-	IssmDouble solution_time;
-	IssmDouble solution_flops;
-	IssmDouble solution_memory;
-
-	/*solution: */
-	int solution_type;
-	void (*solutioncore)(FemModel*)=NULL; //core solution function pointer
-	
-	_pprintLine_("call computational core:");
-
-	/*Retrieve solution_type from parameters: */
-	parameters->FindParam(&solution_type,SolutionTypeEnum);
-
-	/*Figure out which solution core we are going to run with the current solution type: */
-	CorePointerFromSolutionEnum(&solutioncore,this->parameters,solution_type);
-
-	/*run solutoin core: */
-	profiler->Tag(StartCore);   
-	solutioncore(this); 
-	profiler->Tag(FinishCore);
-
-	/*run AD core if needed: */
-	profiler->Tag(StartAdCore); 
-	ad_core(this);      
-	profiler->Tag(FinishAdCore);
-
-	/*some profiling results for the core: */
-	parameters->FindParam(&profiling,DebugProfilingEnum);
-	if(profiling){
-
-		solution_time=profiler->DeltaTime(StartCore,FinishCore);
-		solution_flops=profiler->DeltaFlops(StartCore,FinishCore);
-		solution_memory=profiler->Memory(FinishCore);
-
-		_pprintLine_("Solution elapsed time  : " << solution_time << "  Seconds");
-		_pprintLine_("Solution elapsed flops : " << solution_flops << "  Flops");
-		_pprintLine_("Solution memory used   : " << solution_memory << "  Bytes");
-
-		/*Add to results: */
-		results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingSolutionTimeEnum, solution_time, 1, 0));
-		results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentMemEnum, solution_memory, 1, 0));
-		results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentFlopsEnum, solution_flops, 1, 0));
-	}
-
-}
-/*}}}*/
 /*FUNCTION FemModel::Echo {{{*/
 void FemModel::Echo(void){
@@ -274,4 +141,95 @@
 }
 /*}}}*/
+/*FUNCTION FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){{{*/
+void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){
+
+	/*intermediary*/
+	int         i;
+	int         analysis_type;
+	FILE       *IOMODEL = NULL;
+	FILE       *petscoptionsfid = NULL;
+	FILE       *output_fid = NULL;
+	int         my_rank;
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
+	/*Open input file on cpu 0: */
+	if(my_rank==0) IOMODEL = pfopen(inputfilename ,"rb");
+
+	/*Initialize internal data: */
+	this->nummodels        = nummodels;
+	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
+
+	/*Dynamically allocate whatever is a list of length nummodels: */
+	analysis_type_list=xNew<int>(nummodels);
+
+	/*Initialize: */
+	for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
+
+	/*create datasets for all analyses*/
+	ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,rootpath,this->solution_type,nummodels,analyses);
+
+	/*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
+	for(i=0;i<nummodels;i++){
+
+		if(VerboseMProcessor()) _pprintLine_("   Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":");
+		analysis_type=analysis_type_list[i];
+		this->SetCurrentConfiguration(analysis_type);
+
+		if(i==0){
+			if(VerboseMProcessor()) _pprintLine_("      creating vertex degrees of freedom");
+			VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
+		}
+
+		if(VerboseMProcessor()) _pprintLine_("      resolving node constraints");
+		SpcNodesx(nodes,constraints,parameters,analysis_type); 
+
+		if(VerboseMProcessor()) _pprintLine_("      creating nodal degrees of freedom");
+		NodesDofx(nodes,parameters,analysis_type);
+
+		if(VerboseMProcessor()) _pprintLine_("      configuring element and loads");
+		ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
+	}
+
+	/*Close input file descriptors: */
+	if(my_rank==0) pfclose(IOMODEL,inputfilename);
+
+	/*Open output file once for all and add output file name and file descriptor to parameters*/
+	output_fid=pfopen(outputfilename,"wb");
+	this->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename));
+	this->parameters->SetParam(output_fid,OutputFilePointerEnum);
+
+	/*Save lock file name for later: */
+	this->parameters->AddObject(new StringParam(LockFileNameEnum,lockfilename));
+
+	/*Now, deal with petsc options, which need to be put into the parameters dataset: */
+	petscoptionsfid=pfopen(petscfilename,"r");
+	ParsePetscOptionsx(this->parameters,petscoptionsfid);
+	pfclose(petscoptionsfid,petscfilename);
+}
+/*}}}*/
+/*FUNCTION FemModel::OutputResults {{{*/
+void FemModel::OutputResults(void){
+	
+	_pprintLine_("write results to disk:");
+
+	/*Just call the OutputResultsx module: */
+	OutputResultsx(this->elements, this->nodes, this->vertices, this->loads, this->materials, this->parameters,this->results);
+
+}
+/*}}}*/
+/*FUNCTION FemModel::PrintBanner {{{*/
+void FemModel::PrintBanner(void){
+
+	_pprintLine_("");
+	_pprintLine_("Ice Sheet System Model (" << PACKAGE_NAME << ") version " << PACKAGE_VERSION);
+	_pprintLine_("(website: " << PACKAGE_URL << " contact: " << PACKAGE_BUGREPORT << ")");
+	_pprintLine_("");
+
+}
+/*}}}*/
 /*FUNCTION FemModel::SetStaticComm {{{*/
 void FemModel::SetStaticComm(void){
@@ -283,11 +241,52 @@
 }
 /*}}}*/
-/*FUNCTION FemModel::PrintBanner {{{*/
-void FemModel::PrintBanner(void){
-
-	_pprintLine_("");
-	_pprintLine_("Ice Sheet System Model (" << PACKAGE_NAME << ") version " << PACKAGE_VERSION);
-	_pprintLine_("(website: " << PACKAGE_URL << " contact: " << PACKAGE_BUGREPORT << ")");
-	_pprintLine_("");
+/*FUNCTION FemModel::Solve {{{*/
+void FemModel::Solve(void){
+
+	/*profiling: */
+	bool profiling = false;
+	IssmDouble solution_time;
+	IssmDouble solution_flops;
+	IssmDouble solution_memory;
+
+	/*solution: */
+	int solution_type;
+	void (*solutioncore)(FemModel*)=NULL; //core solution function pointer
+	
+	_pprintLine_("call computational core:");
+
+	/*Retrieve solution_type from parameters: */
+	parameters->FindParam(&solution_type,SolutionTypeEnum);
+
+	/*Figure out which solution core we are going to run with the current solution type: */
+	CorePointerFromSolutionEnum(&solutioncore,this->parameters,solution_type);
+
+	/*run solutoin core: */
+	profiler->Tag(StartCore);   
+	solutioncore(this); 
+	profiler->Tag(FinishCore);
+
+	/*run AD core if needed: */
+	profiler->Tag(StartAdCore); 
+	ad_core(this);      
+	profiler->Tag(FinishAdCore);
+
+	/*some profiling results for the core: */
+	parameters->FindParam(&profiling,DebugProfilingEnum);
+	if(profiling){
+
+		solution_time=profiler->DeltaTime(StartCore,FinishCore);
+		solution_flops=profiler->DeltaFlops(StartCore,FinishCore);
+		solution_memory=profiler->Memory(FinishCore);
+
+		_pprintLine_("Solution elapsed time  : " << solution_time << "  Seconds");
+		_pprintLine_("Solution elapsed flops : " << solution_flops << "  Flops");
+		_pprintLine_("Solution memory used   : " << solution_memory << "  Bytes");
+
+		/*Add to results: */
+		results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingSolutionTimeEnum, solution_time, 1, 0));
+		results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentMemEnum, solution_memory, 1, 0));
+		results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentFlopsEnum, solution_flops, 1, 0));
+	}
 
 }
