Index: ../trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
===================================================================
--- ../trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.cpp	(revision 18528)
+++ ../trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.cpp	(revision 18529)
@@ -12,7 +12,7 @@
 #include "../../shared/shared.h"
 #include "./ModelProcessorx.h"
 
-void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters, FILE* IOMODEL,FILE* toolkitfile, char* rootpath,const int solution_enum,const int nummodels,const int* analysis_enum_list){
+void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters,IoModel* iomodel,FILE* toolkitfile, char* rootpath,const int solution_enum,const int nummodels,const int* analysis_enum_list){
 
 	int   i,analysis_enum,verbose;
 	bool  isthermal,ismasstransport,isstressbalance,isgroundingline,isenthalpy,islevelset,isdamage,ishydrology;
@@ -26,9 +26,6 @@
 	Loads       *loads       = new Loads();
 	Parameters  *parameters  = new Parameters();
 
-	/*Initialize IoModel from input file*/
-	IoModel* iomodel = new IoModel(IOMODEL);
-
 	/*Fetch parameters: */
 	iomodel->Constant(&verbose,VerboseEnum);
 	iomodel->Constant(&isthermal,TransientIsthermalEnum);
@@ -127,9 +124,6 @@
 	parameters->Presort();
 	if(VerboseMProcessor()) _printf0_("   done with model processor \n");
 
-	/*Free resources:*/
-	delete iomodel;
-
 	/*Assign output pointers:*/
 	*pelements    = elements;
 	*pnodes       = nodes;
Index: ../trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h
===================================================================
--- ../trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h	(revision 18528)
+++ ../trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h	(revision 18529)
@@ -8,7 +8,7 @@
 #include "../../classes/classes.h"
 #include "../../analyses/analyses.h"
 
-void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters, FILE* iomodel_handle,FILE* toolkitfile, char* rootpath,const int solution_type,const int nummodels,const int* analysis_type_listh);
+void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters,IoModel* iomodel,FILE* toolkitfile, char* rootpath,const int solution_type,const int nummodels,const int* analysis_type_listh);
 
 /*Creation of fem datasets: general drivers*/
 void CreateElementsVerticesAndMaterials(Elements* elements,Vertices* vertices,Materials* materials, IoModel* iomodel,const int nummodels);
Index: ../trunk-jpl/src/c/Makefile.am
===================================================================
--- ../trunk-jpl/src/c/Makefile.am	(revision 18528)
+++ ../trunk-jpl/src/c/Makefile.am	(revision 18529)
@@ -341,7 +341,6 @@
 					./modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h\
 					./cores/ProcessArguments.cpp\
 					./cores/ResetBoundaryConditions.cpp\
-					./cores/AnalysisConfiguration.cpp\
 					./cores/WrapperCorePointerFromSolutionEnum.cpp\
 					./cores/CorePointerFromSolutionEnum.cpp\
 					./cores/ad_core.cpp\
Index: ../trunk-jpl/src/c/cores/AnalysisConfiguration.cpp
===================================================================
--- ../trunk-jpl/src/c/cores/AnalysisConfiguration.cpp	(revision 18528)
+++ ../trunk-jpl/src/c/cores/AnalysisConfiguration.cpp	(revision 18529)
@@ -1,165 +0,0 @@
-/*!\file:  AnalysisConfiguration.cpp
- * \brief: return type of analyses, number of analyses 
- */ 
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include "./cores.h"
-#include "../toolkits/toolkits.h"
-#include "../classes/classes.h"
-#include "../shared/shared.h"
-#include "../modules/modules.h"
-#include "../solutionsequences/solutionsequences.h"
-
-void AnalysisConfiguration(int** panalyses,int* pnumanalyses, int solutiontype){
-
-	/*output: */
-	int  numanalyses;
-	int* analyses=NULL;
-
-	/*Analyses lists*/
-	switch(solutiontype){
-
-		case StressbalanceSolutionEnum:
-			numanalyses=6;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=StressbalanceAnalysisEnum;
-			analyses[1]=StressbalanceVerticalAnalysisEnum;
-			analyses[2]=StressbalanceSIAAnalysisEnum;
-			analyses[3]=L2ProjectionBaseAnalysisEnum;
-			analyses[4]=ExtrudeFromBaseAnalysisEnum;
-			analyses[5]=DepthAverageAnalysisEnum;
-			//analyses[6]=UzawaPressureAnalysisEnum;
-			break;
-
-		case SteadystateSolutionEnum:
-			numanalyses=7;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=StressbalanceAnalysisEnum;
-			analyses[1]=StressbalanceVerticalAnalysisEnum;
-			analyses[2]=StressbalanceSIAAnalysisEnum;
-			analyses[3]=L2ProjectionBaseAnalysisEnum;
-			analyses[4]=EnthalpyAnalysisEnum;
-			analyses[5]=ThermalAnalysisEnum;
-			analyses[6]=MeltingAnalysisEnum;
-			break;
-
-		case ThermalSolutionEnum:
-			numanalyses=3;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=ThermalAnalysisEnum;
-			analyses[1]=MeltingAnalysisEnum;
-			analyses[2]=EnthalpyAnalysisEnum;
-			break;
-
-		case HydrologySolutionEnum:
-			numanalyses=5;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=HydrologyShreveAnalysisEnum;
-			analyses[1]=HydrologyDCInefficientAnalysisEnum;
-			analyses[2]=HydrologyDCEfficientAnalysisEnum;
-			analyses[3]=L2ProjectionBaseAnalysisEnum;
-			analyses[4]=L2ProjectionEPLAnalysisEnum;
-			break;
-
-		case MasstransportSolutionEnum:
-			numanalyses=1;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=MasstransportAnalysisEnum;
-			break;
-
-		case BalancethicknessSolutionEnum:
-			numanalyses=1;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=BalancethicknessAnalysisEnum;
-			break;
-
-		case Balancethickness2SolutionEnum:
-			numanalyses=1;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=Balancethickness2AnalysisEnum;
-			break;
-
-		case BalancethicknessSoftSolutionEnum:
-			numanalyses=1;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=BalancethicknessAnalysisEnum;
-			break;
-
-		case BalancevelocitySolutionEnum:
-			numanalyses=3;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=BalancevelocityAnalysisEnum;
-			analyses[1]=SmoothedSurfaceSlopeXAnalysisEnum;
-			analyses[2]=SmoothedSurfaceSlopeYAnalysisEnum;
-			break;
-
-		case SurfaceSlopeSolutionEnum:
-			numanalyses=1;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=L2ProjectionBaseAnalysisEnum;
-			break;
-
-		case BedSlopeSolutionEnum:
-			numanalyses=1;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=L2ProjectionBaseAnalysisEnum;
-			break;
-
-		case GiaSolutionEnum:
-			numanalyses=1;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=GiaAnalysisEnum;
-			break;
-		
-		case DamageEvolutionSolutionEnum:
-			numanalyses=1;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=DamageEvolutionAnalysisEnum;
-			break;
-
-		case TransientSolutionEnum:
-			numanalyses=20;
-			analyses=xNew<int>(numanalyses);
-			analyses[ 0]=StressbalanceAnalysisEnum;
-			analyses[ 1]=StressbalanceVerticalAnalysisEnum;
-			analyses[ 2]=StressbalanceSIAAnalysisEnum;
-			analyses[ 3]=L2ProjectionBaseAnalysisEnum;
-			analyses[ 4]=ThermalAnalysisEnum;
-			analyses[ 5]=MeltingAnalysisEnum;
-			analyses[ 6]=EnthalpyAnalysisEnum;
-			analyses[ 7]=MasstransportAnalysisEnum;
-			analyses[ 8]=FreeSurfaceBaseAnalysisEnum;
-			analyses[ 9]=FreeSurfaceTopAnalysisEnum;
-			analyses[10]=ExtrudeFromBaseAnalysisEnum;
-			analyses[11]=ExtrudeFromTopAnalysisEnum;
-			analyses[12]=LevelsetAnalysisEnum;
-			analyses[13]=ExtrapolationAnalysisEnum;
-			analyses[14]=LsfReinitializationAnalysisEnum;
-			analyses[15]=DamageEvolutionAnalysisEnum;
-			analyses[16]=HydrologyShreveAnalysisEnum;
-			analyses[17]=HydrologyDCInefficientAnalysisEnum;
-			analyses[18]=HydrologyDCEfficientAnalysisEnum;
-			analyses[19]=L2ProjectionEPLAnalysisEnum;
-			break;
-
-		case SeaiceSolutionEnum:
-			numanalyses=1;
-			analyses=xNew<int>(numanalyses);
-			analyses[0]=SeaiceAnalysisEnum;
-			break;
-
-		default:
-			_error_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!");
-			break;
-	}
-
-	/*Assign output pointers:*/
-	if(pnumanalyses) *pnumanalyses=numanalyses;
-	if(panalyses)    *panalyses=analyses;
-	else              xDelete<int>(analyses);
-}
Index: ../trunk-jpl/src/c/cores/cores.h
===================================================================
--- ../trunk-jpl/src/c/cores/cores.h	(revision 18528)
+++ ../trunk-jpl/src/c/cores/cores.h	(revision 18529)
@@ -57,7 +57,6 @@
 void PrintBanner(void);
 
 //solution configuration
-void AnalysisConfiguration(int** pcores,int* pnumcores, int solutiontype);
 void CorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype);
 void WrapperCorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype,bool nodakotacore=false);
 void AdjointCorePointerFromSolutionEnum(void (**padjointcore)(FemModel*),int solutiontype);
Index: ../trunk-jpl/src/c/classes/FemModel.cpp
===================================================================
--- ../trunk-jpl/src/c/classes/FemModel.cpp	(revision 18528)
+++ ../trunk-jpl/src/c/classes/FemModel.cpp	(revision 18529)
@@ -74,12 +74,9 @@
 	/*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);
+	this->InitFromFiles(rootpath,binfilename,outbinfilename,petscfilename,lockfilename,solution_type);
 	profiler->Tag(FinishInit);
 
 	/*Free resources */
@@ -92,13 +89,6 @@
 
 }
 /*}}}*/
-FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, 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, toolkitsfilename, lockfilename, in_solution_type,analyses,nummodels);
-
-}
-/*}}}*/
 FemModel::~FemModel(){/*{{{*/
 
 	/*Intermediary*/
@@ -140,7 +130,7 @@
 
 }
 /*}}}*/
-void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){/*{{{*/
+void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, const int in_solution_type){/*{{{*/
 
 	/*intermediary*/
 	int         i;
@@ -153,26 +143,23 @@
 	/*recover my_rank:*/
 	my_rank=IssmComm::GetRank();
 
-	/*Open input file on cpu 0: */
-	if(my_rank==0) IOMODEL = pfopen0(inputfilename ,"rb");
-
-	/*Open toolkits file: */
-	toolkitsoptionsfid=pfopen(toolkitsfilename,"r");
-
 	/*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);
+	/*Open input file on cpu 0 and create IoModel */
+	if(my_rank==0) IOMODEL = pfopen0(inputfilename ,"rb");
+	IoModel* iomodel = new IoModel(IOMODEL);
 
-	/*Initialize: */
-	for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
+	/*Figure out what analyses are activated for this solution*/
+	SolutionAnalysesList(&this->analysis_type_list,&this->nummodels,iomodel,this->solution_type);
 
+	/*Open toolkits file: */
+	toolkitsoptionsfid=pfopen(toolkitsfilename,"r");
+
 	/*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,nummodels,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++){
@@ -208,8 +195,9 @@
 	/*Save lock file name for later: */
 	this->parameters->AddObject(new StringParam(LockFileNameEnum,lockfilename));
 
-	}
-/*}}}*/
+	/*Clean up*/
+	delete iomodel;
+}/*}}}*/
 void FemModel::CleanUp(void){/*{{{*/
 
 	/*Intermediary*/
@@ -411,7 +399,144 @@
 	return output;
 }
 /*}}}*/
+void  FemModel::SolutionAnalysesList(int** panalyses,int* pnumanalyses,IoModel* iomodel,int solutiontype){/*{{{*/
 
+	/*output: */
+	int  numanalyses = 0;
+	int* analyses=NULL;
+
+	/*Intermediaries*/
+	const int MAXANALYSES = 30;
+	int   analyses_temp[MAXANALYSES];
+
+	/*Analyses lists*/
+	switch(solutiontype){
+
+		case StressbalanceSolutionEnum:{
+			bool isSIA,isFS;
+			int  fe_FS;
+			iomodel->Constant(&fe_FS,FlowequationFeFSEnum);
+			iomodel->Constant(&isSIA,FlowequationIsSIAEnum);
+			iomodel->Constant(&isFS,FlowequationIsFSEnum);
+			analyses_temp[numanalyses++]=StressbalanceAnalysisEnum;
+			analyses_temp[numanalyses++]=StressbalanceVerticalAnalysisEnum;
+			if(isSIA){
+				analyses_temp[numanalyses++]=StressbalanceSIAAnalysisEnum;
+			}
+			analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum;
+			analyses_temp[numanalyses++]=ExtrudeFromBaseAnalysisEnum;
+			analyses_temp[numanalyses++]=DepthAverageAnalysisEnum;
+			if(fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum){
+				analyses_temp[numanalyses++]=UzawaPressureAnalysisEnum;
+			}
+			}
+			break;
+
+		case SteadystateSolutionEnum:
+			analyses_temp[numanalyses++]=StressbalanceAnalysisEnum;
+			analyses_temp[numanalyses++]=StressbalanceVerticalAnalysisEnum;
+			analyses_temp[numanalyses++]=StressbalanceSIAAnalysisEnum;
+			analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum;
+			analyses_temp[numanalyses++]=EnthalpyAnalysisEnum;
+			analyses_temp[numanalyses++]=ThermalAnalysisEnum;
+			analyses_temp[numanalyses++]=MeltingAnalysisEnum;
+			break;
+
+		case ThermalSolutionEnum:
+			analyses[numanalyses++]=ThermalAnalysisEnum;
+			analyses[numanalyses++]=MeltingAnalysisEnum;
+			analyses[numanalyses++]=EnthalpyAnalysisEnum;
+			break;
+
+		case HydrologySolutionEnum:
+			analyses[numanalyses++]=HydrologyShreveAnalysisEnum;
+			analyses[numanalyses++]=HydrologyDCInefficientAnalysisEnum;
+			analyses[numanalyses++]=HydrologyDCEfficientAnalysisEnum;
+			analyses[numanalyses++]=L2ProjectionBaseAnalysisEnum;
+			analyses[numanalyses++]=L2ProjectionEPLAnalysisEnum;
+			break;
+
+		case MasstransportSolutionEnum:
+			analyses[numanalyses++]=MasstransportAnalysisEnum;
+			break;
+
+		case BalancethicknessSolutionEnum:
+			analyses[numanalyses++]=BalancethicknessAnalysisEnum;
+			break;
+
+		case Balancethickness2SolutionEnum:
+			analyses[numanalyses++]=Balancethickness2AnalysisEnum;
+			break;
+
+		case BalancethicknessSoftSolutionEnum:
+			analyses[numanalyses++]=BalancethicknessAnalysisEnum;
+			break;
+
+		case BalancevelocitySolutionEnum:
+			analyses[numanalyses++]=BalancevelocityAnalysisEnum;
+			analyses[numanalyses++]=SmoothedSurfaceSlopeXAnalysisEnum;
+			analyses[numanalyses++]=SmoothedSurfaceSlopeYAnalysisEnum;
+			break;
+
+		case SurfaceSlopeSolutionEnum:
+			analyses[numanalyses++]=L2ProjectionBaseAnalysisEnum;
+			break;
+
+		case BedSlopeSolutionEnum:
+			analyses[numanalyses++]=L2ProjectionBaseAnalysisEnum;
+			break;
+
+		case GiaSolutionEnum:
+			analyses[numanalyses++]=GiaAnalysisEnum;
+			break;
+		
+		case DamageEvolutionSolutionEnum:
+			analyses[numanalyses++]=DamageEvolutionAnalysisEnum;
+			break;
+
+		case TransientSolutionEnum:
+			analyses_temp[numanalyses++]=StressbalanceAnalysisEnum;
+			analyses_temp[numanalyses++]=StressbalanceVerticalAnalysisEnum;
+			analyses_temp[numanalyses++]=StressbalanceSIAAnalysisEnum;
+			analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum;
+			analyses_temp[numanalyses++]=ThermalAnalysisEnum;
+			analyses_temp[numanalyses++]=MeltingAnalysisEnum;
+			analyses_temp[numanalyses++]=EnthalpyAnalysisEnum;
+			analyses_temp[numanalyses++]=MasstransportAnalysisEnum;
+			analyses_temp[numanalyses++]=FreeSurfaceBaseAnalysisEnum;
+			analyses_temp[numanalyses++]=FreeSurfaceTopAnalysisEnum;
+			analyses_temp[numanalyses++]=ExtrudeFromBaseAnalysisEnum;
+			analyses_temp[numanalyses++]=ExtrudeFromTopAnalysisEnum;
+			analyses_temp[numanalyses++]=LevelsetAnalysisEnum;
+			analyses_temp[numanalyses++]=ExtrapolationAnalysisEnum;
+			analyses_temp[numanalyses++]=LsfReinitializationAnalysisEnum;
+			analyses_temp[numanalyses++]=DamageEvolutionAnalysisEnum;
+			analyses_temp[numanalyses++]=HydrologyShreveAnalysisEnum;
+			analyses_temp[numanalyses++]=HydrologyDCInefficientAnalysisEnum;
+			analyses_temp[numanalyses++]=HydrologyDCEfficientAnalysisEnum;
+			analyses_temp[numanalyses++]=L2ProjectionEPLAnalysisEnum;
+			break;
+
+		case SeaiceSolutionEnum:
+			analyses_temp[numanalyses++]=SeaiceAnalysisEnum;
+			break;
+
+		default:
+			_error_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!");
+			break;
+	}
+
+	/*Copy analyses from temp to output*/
+	_assert_(numanalyses<MAXANALYSES);
+	analyses=xNew<int>(numanalyses);
+	for(int i=0;i<numanalyses;i++) analyses[i]=analyses_temp[i];
+
+	/*Assign output pointers:*/
+	if(pnumanalyses) *pnumanalyses=numanalyses;
+	if(panalyses)    *panalyses=analyses;
+	else              xDelete<int>(analyses);
+}/*}}}*/
+
 /*Modules:*/
 int  FemModel::UpdateVertexPositionsx(void){ /*{{{*/
 
Index: ../trunk-jpl/src/c/classes/FemModel.h
===================================================================
--- ../trunk-jpl/src/c/classes/FemModel.h	(revision 18528)
+++ ../trunk-jpl/src/c/classes/FemModel.h	(revision 18529)
@@ -46,13 +46,13 @@
 
 		/*constructors, destructors: */
 		FemModel(int argc,char** argv,ISSM_MPI_Comm comm_init);
-		FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
 		~FemModel();
 
 		/*Methods:*/
 		void Echo();
 		FemModel* copy();
-		void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
+		void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type);
+		void SolutionAnalysesList(int** panalyses,int* pnumanalyses,IoModel* iomodel,int solutiontype);
 		void CleanUp(void);
 		void Solve(void);
 		void SetStaticComm();
