Index: /issm/trunk-jpl/src/c/classes/FemModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 13552)
+++ /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 13553)
@@ -12,4 +12,5 @@
 #include "../Container/Container.h"
 #include "../modules/ModelProcessorx/ModelProcessorx.h"
+#include "../solutions/solutions.h"
 #include "../io/io.h"
 #include "./classes.h"
@@ -19,7 +20,55 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION FemModel::constructor {{{*/
+/*FUNCTION FemModel::FemModel(int argc,char** argv){{{*/
+FemModel::FemModel(int argc,char** argv){
+
+	/*configuration: */
+	int* analyses=NULL;
+	int  numanalyses;
+	int  solution_type;
+
+	/*File names*/
+	char *lockfilename   = NULL;
+	char *binfilename    = NULL;
+	char *outbinfilename = NULL;
+	char *petscfilename  = NULL;
+	char *rootpath       = NULL;
+
+	/*Start profiler: */
+	this->profiler=new Profiler();
+	profiler->Tag(Start);
+
+	/*From command line arguments, retrieve different filenames needed to create the FemModel: */
+	ProcessArguments(&solution_type,&binfilename,&outbinfilename,&petscfilename,&lockfilename,&rootpath,argc,argv);
+
+	/*out of solution_type, figure out types of analyses needed in the femmodel: */
+	AnalysisConfiguration(&analyses,&numanalyses,solution_type);
+
+	/*Create femmodel from input files: */
+	profiler->Tag(StartInit);
+	this->InitFromFiles(rootpath,binfilename,outbinfilename,petscfilename,lockfilename,solution_type,analyses,numanalyses);
+	profiler->Tag(FinishInit);
+
+	/*Free resources */
+	xDelete<int>(analyses);
+	xDelete<char>(lockfilename);
+	xDelete<char>(binfilename);
+	xDelete<char>(outbinfilename);
+	xDelete<char>(petscfilename);
+	xDelete<char>(rootpath);
+
+}
+/*}}}*/
+/*FUNCTION FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){{{*/
 FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){
 
+	/*Call InitFromFiles. This constructor is just a wrapper: */
+	this->InitFromFiles(rootpath, inputfilename, outputfilename, petscfilename, lockfilename, in_solution_type,analyses,nummodels);
+
+}
+/*}}}*/
+/*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;
@@ -122,4 +171,5 @@
 	delete parameters;
 	delete results;
+	delete profiler;
 
 }
@@ -127,4 +177,31 @@
 
 /*Object management*/
+/*FUNCTION FemModel::Solve {{{*/
+void FemModel::Solve(void){
+
+	int solution_type;
+	void (*solutioncore)(FemModel*)=NULL; //core solution function pointer
+	
+	_pprintLine_("call computational core:");
+
+	/*Retrieve solution_type from parameters: */
+	this->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);
+
+
+}
+/*}}}*/
 /*FUNCTION FemModel::Echo {{{*/
 void FemModel::Echo(void){
Index: /issm/trunk-jpl/src/c/classes/FemModel.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/FemModel.h	(revision 13552)
+++ /issm/trunk-jpl/src/c/classes/FemModel.h	(revision 13553)
@@ -19,4 +19,5 @@
 class Loads;
 class Materials;
+class Profiler;
 /*}}}*/
 
@@ -33,4 +34,6 @@
 		int          analysis_counter;     //counter into analysis_type_list
 
+		Profiler*    profiler;             //keep time, cpu and mem statistics while we are running.
+
 		Elements    *elements;             //elements (one set for all analyses)
 		Nodes       *nodes;                //one set of nodes
@@ -43,9 +46,12 @@
 
 		/*constructors, destructors: */
+		FemModel(int argc,char** argv);
 		FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
 		~FemModel();
+		void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
 
 		/*Methods: */
 		void Echo();
+		void Solve(void);
 
 		/*Fem: */
Index: /issm/trunk-jpl/src/c/solutions/issm.cpp
===================================================================
--- /issm/trunk-jpl/src/c/solutions/issm.cpp	(revision 13552)
+++ /issm/trunk-jpl/src/c/solutions/issm.cpp	(revision 13553)
@@ -14,19 +14,10 @@
 	FemModel *femmodel = NULL;
 
-	/*configuration: */
-	void (*solutioncore)(FemModel*)=NULL; //core solution function pointer
-	int* analyses=NULL;
-	int  numanalyses;
-	int  solution_type;
-
-	/*File names*/
-	char *lockfilename   = NULL;
-	char *binfilename    = NULL;
-	char *outbinfilename = NULL;
-	char *petscfilename  = NULL;
-	char *rootpath       = NULL;
-
-	/*profiling*/   
-	Profiler* profiler=NULL;
+	/*Print starting banner: {{{*/
+	_pprintLine_("");
+	_pprintLine_("Ice Sheet System Model (" << PACKAGE_NAME << ") version " << PACKAGE_VERSION);
+	_pprintLine_("(website: " << PACKAGE_URL << " contact: " << PACKAGE_BUGREPORT << ")");
+	_pprintLine_(""); 
+	/*}}}*/
 
 	/*Initialize exception trapping: */
@@ -35,31 +26,13 @@
 	/*Initialize environment (MPI, PETSC, MUMPS, etc ...)*/
 	EnvironmentInit(argc,argv);
-	
-	/*Start profiler: */
-	profiler=new Profiler(); 
-	profiler->Tag(Start);
-	
-	/*First process inputs*/
-	_pprintLine_("");
-	_pprintLine_("Ice Sheet System Model (" << PACKAGE_NAME << ") version " << PACKAGE_VERSION);
-	_pprintLine_("(website: " << PACKAGE_URL << " contact: " << PACKAGE_BUGREPORT << ")");
-	_pprintLine_("");
+		
+	/*Initialize femmodel from arguments provided command line: */
+	femmodel=new FemModel(argc,argv);
 
-	ProcessArguments(&solution_type,&binfilename,&outbinfilename,&petscfilename,&lockfilename,&rootpath,argc,argv);
+	/*Solve: */
+	femmodel->Solve();
 
-	/*out of solution_type, figure out types of analyses needed in the femmodel: */
-	AnalysisConfiguration(&analyses,&numanalyses,solution_type);
-
-	/*Create femmodel from input files: */
-	profiler->Tag(StartInit);
-	femmodel=new FemModel(rootpath,binfilename,outbinfilename,petscfilename,lockfilename,solution_type,analyses,numanalyses);
-	profiler->Tag(FinishInit);
-	
-	/*call cores: */
-	_pprintLine_("call computational core:");
-	CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);
-	profiler->Tag(StartCore);   solutioncore(femmodel); profiler->Tag(FinishCore); 
-	profiler->Tag(StartAdCore); ad_core(femmodel);      profiler->Tag(FinishAdCore); 
-	ProfilerEnd(profiler,femmodel->results,femmodel->parameters);
+	/*Some profiling: */
+	ProfilerEnd(femmodel->profiler,femmodel->results,femmodel->parameters);
 
 	_pprintLine_("write results to disk:");
@@ -67,14 +40,8 @@
 	
 	/*Profiling at the end: */
-	profiler->Tag(Finish); 
-	ProfilerEcho(profiler);
+	femmodel->profiler->Tag(Finish); 
+	ProfilerEcho(femmodel->profiler);
 	
-	/*Free resources */
-	xDelete<int>(analyses);
-	xDelete<char>(lockfilename);
-	xDelete<char>(binfilename);
-	xDelete<char>(outbinfilename);
-	xDelete<char>(petscfilename);
-	xDelete<char>(rootpath);
+	/*Wrap up: */
 	delete femmodel;
 
