Index: /issm/branches/trunk-larour-SLPS2020/src/c/main/issm_dakota.cpp
===================================================================
--- /issm/branches/trunk-larour-SLPS2020/src/c/main/issm_dakota.cpp	(revision 25604)
+++ /issm/branches/trunk-larour-SLPS2020/src/c/main/issm_dakota.cpp	(revision 25605)
@@ -16,5 +16,5 @@
 
 /*prototypes:*/
-int dirstructure(int argc,char** argv);
+bool dirstructure(int argc,char** argv);
 int issm_dakota_statistics(int argc,char** argv);
 
@@ -27,4 +27,5 @@
 	char* dakota_output_file = NULL;
 	char* dakota_error_file = NULL;
+	bool statistics=false;
 
 	/*Define MPI_DEBUG in dakota_global_defs.cpp to cause a hold here*/
@@ -45,5 +46,5 @@
 
 	/*Create directory structure for model outputs:*/
-	dirstructure(argc,argv);
+	statistics=dirstructure(argc,argv);
 
 	/* Parse input and construct Dakota LibraryEnvironment, performing input data checks*/
@@ -92,5 +93,5 @@
 
 	/* Run statistics if requested:*/
-	issm_dakota_statistics(argc,argv);
+	if(statistics)issm_dakota_statistics(argc,argv);
 
 	/*free allocations:*/
@@ -107,5 +108,5 @@
 
 } /*}}}*/
-int dirstructure(int argc,char** argv){ /*{{{*/
+bool dirstructure(int argc,char** argv){ /*{{{*/
 
 	char* input_file; 
@@ -141,5 +142,5 @@
 		delete iomodel;
 		fclose(fid); 
-		return 0;
+		return false; //important return value!
 	}
 
@@ -159,4 +160,7 @@
 	//close model file: 
 	fclose(fid);
+
+	//return value: 
+	return true; //statistics computation on!
 } /*}}}*/
 int issm_dakota_statistics(int argc,char** argv){ /*{{{*/
@@ -285,5 +289,5 @@
 				/*fetch indices: */
 				sprintf(string,"md.qmu.statistics.method(%i).indices",i);
-				iomodel->FetchData(&indices,&nindices,&dummy,string);
+				iomodel->FetchData(&indices,&dummy,&nindices,string);
 				parameters->AddObject(new IntVecParam(IndicesEnum,indices,nindices));
 		
Index: /issm/branches/trunk-larour-SLPS2020/src/c/modules/OutputResultsx/OutputResultsx.cpp
===================================================================
--- /issm/branches/trunk-larour-SLPS2020/src/c/modules/OutputResultsx/OutputResultsx.cpp	(revision 25604)
+++ /issm/branches/trunk-larour-SLPS2020/src/c/modules/OutputResultsx/OutputResultsx.cpp	(revision 25605)
@@ -74,7 +74,7 @@
 				femmodel->parameters->FindParam(&currEvalId,QmuCurrEvalIdEnum);
 				femmodel->parameters->FindParam(&statistics,QmuStatisticsEnum);
-				femmodel->parameters->FindParam(&nfilesperdirectory,QmuNfilesPerDirectoryEnum);
 
 				if(statistics){
+					femmodel->parameters->FindParam(&nfilesperdirectory,QmuNfilesPerDirectoryEnum);
 					femmodel->parameters->FindParam(&root,RootPathEnum);
 					femmodel->parameters->FindParam(&modelname,ModelnameEnum);
Index: /issm/branches/trunk-larour-SLPS2020/src/c/modules/QmuStatisticsx/QmuStatisticsx.cpp
===================================================================
--- /issm/branches/trunk-larour-SLPS2020/src/c/modules/QmuStatisticsx/QmuStatisticsx.cpp	(revision 25604)
+++ /issm/branches/trunk-larour-SLPS2020/src/c/modules/QmuStatisticsx/QmuStatisticsx.cpp	(revision 25605)
@@ -1003,4 +1003,5 @@
 	int nfields;
 	int range,lower_row,upper_row;
+	int nfilesperdirectory;
 	int* indices=NULL;
 	int  nindices;
@@ -1018,4 +1019,7 @@
 	int*         xsize=NULL;
 
+	/*only work on the statistical communicator: */
+	if (color==MPI_UNDEFINED)return 0;
+
 	/*Retrieve parameters:*/
 	parameters->FindParam(&nsamples,QmuNsampleEnum);
@@ -1026,5 +1030,6 @@
 	parameters->FindParam(&indices,&nindices,IndicesEnum);
 
-	/*Get rank:*/
+	/*Get rank from the stat comm communicator:*/
+	IssmComm::SetComm(statcomm);
 	int my_rank=IssmComm::GetRank();
 
@@ -1144,5 +1149,6 @@
 		}
 	}
-
+	_printf0_("Done with SampleSeries :\n");
+	IssmComm::SetComm(ISSM_MPI_COMM_WORLD);
 
 } /*}}}*/
