Index: /issm/trunk-jpl/src/wrappers/ExpSimplify/ExpSimplify.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/ExpSimplify/ExpSimplify.cpp	(revision 14343)
+++ /issm/trunk-jpl/src/wrappers/ExpSimplify/ExpSimplify.cpp	(revision 14344)
@@ -13,7 +13,11 @@
 	_pprintLine_("      - expfile: name of the exp file");
 	_pprintLine_("      - tol:  tolerance (maximal euclidean distance allowed between the new line and a vertex)");
+	_pprintLine_("      Additional options:");
+	_pprintLine_("      - 'remove1': remove singleton from exp file (default is true)");
+	_pprintLine_("      - 'remove2': remove pairs from exp file (default is true)");
 	_pprintLine_("");
 	_pprintLine_("   Example:");
 	_pprintLine_("      ExpSimplify('file.exp',100);");
+	_pprintLine_("      ExpSimplify('file.exp',100,'remove1',false);");
 }/*}}}*/
 void simplify(Contour<double>* contour,bool* flags,int ind0,int ind1,double tolerance){/*{{{*/
@@ -93,4 +97,6 @@
 	char*    expfile  = NULL;
 	double   tolerance;
+	bool     remove1,remove2,save;
+	Options *options      = NULL;
 
 	/*output*/
@@ -102,9 +108,13 @@
 
 	/*checks on arguments: */
-	CHECKARGUMENTS(NLHS,NRHS,&ExpSimplifyUsage);
+	/*checks on arguments on the matlab side: */
+	if (nrhs<NRHS || nlhs>NLHS){
+		ExpSimplifyUsage(); _error_("ExpSimplify usage error");
+	}
 
 	/*Input datasets: */
 	FetchData(&expfile,  EXPFILE);
 	FetchData(&tolerance,TOLERANCE);
+	FetchData(&options,NRHS,nrhs,prhs);
 
 	/*some checks*/
@@ -119,4 +129,8 @@
 	double* y = NULL;
 	double distance;
+
+	/*Process options*/
+	options->Get(&remove1,"remove1",true);
+	options->Get(&remove2,"remove2",true);
 
 	/*Read old contours and allocate new contours*/
@@ -165,6 +179,18 @@
 		newnods = 0;
 		for(int i=0;i<nods;i++) if(flags[i]) newnods++;
-		printf("   New     number of vertices in contour #%i: %i\n",counter+1,newnods);
-		if(newnods){
+
+		/*Do we save new profile?*/
+		save = true;
+		if(newnods==0){
+			save = false;
+		}
+		else if(remove1 && newnods==1){
+			save = false;
+		}
+		else if(remove2 && newnods==2){
+			save = false;
+		}
+		if(save){
+			printf("   New     number of vertices in contour #%i: %i\n",counter+1,newnods);
 			newcontour       = xNew<Contour<double> >(1);
 			newcontour->nods = newnods;
@@ -184,4 +210,7 @@
 			newcontours->AddObject(newcontour);
 		}
+		else{
+			printf("   New     number of vertices in contour #%i: %i (not saved)\n",counter+1,newnods);
+		}
 
 		/*cleanup*/
@@ -194,4 +223,5 @@
 	/*Clean-up*/
 	xDelete<char>(expfile);
+	delete options;
 
 	/*end module: */
