Index: /issm/trunk/src/mex/KMLMeshWrite/KMLMeshWrite.cpp
===================================================================
--- /issm/trunk/src/mex/KMLMeshWrite/KMLMeshWrite.cpp	(revision 7733)
+++ /issm/trunk/src/mex/KMLMeshWrite/KMLMeshWrite.cpp	(revision 7734)
@@ -13,5 +13,4 @@
 	char*   notes=NULL;
 	const mxArray* notesi;
-	mwSize         nsize;
 	mwIndex        nindex;
 
@@ -42,4 +41,6 @@
 
 	FILE*   fid=NULL;
+
+	DataSet* options=NULL;
 
 	/* output: */
@@ -52,9 +53,9 @@
 	if (nlhs > NLHS) {
 		KMLMeshWriteUsage();
-		_error_("KMLMeshWriteUsage usage error");
-	}
-	if (nrhs != NRHS) {
+		_error_("KMLMeshWrite usage error");
+	}
+	if (nrhs < NRHS) {
 		KMLMeshWriteUsage();
-		_error_("KMLMeshWriteUsage usage error");
+		_error_("KMLMeshWrite usage error");
 	}
 
@@ -66,6 +67,5 @@
 /*  notes is typically a cell array of character strings  */
 	if (mxIsCell(NOTES)) {
-		nsize=mxGetNumberOfElements(NOTES);
-		for (nindex=0; nindex<nsize; nindex++) {
+		for (nindex=0; nindex<mxGetNumberOfElements(NOTES); nindex++) {
 			notesi=mxGetCell(NOTES,nindex);
 			if (notesi && mxIsChar(notesi) && mxGetNumberOfElements(notesi)) {
@@ -107,4 +107,9 @@
 	if (verbose) printf("  filnam =\"%s\"\n",filnam);
 
+	if (nrhs > NRHS) {
+		if (verbose) printf("Parsing options:\n");
+		options=OptionsParse(NRHS,nrhs,prhs);
+	}
+
 	/*some checks*/
 	if (verbose) printf("Checking inputs:\n");
@@ -158,4 +163,9 @@
 	WriteData(ERRORFLAG,ierror);
 
+	if (options) {
+		delete options;
+		options=NULL;
+	}
+
 	if (mxIsCell(NOTES) && notes)
 		xfree((void**)&notes);
@@ -191,2 +201,3 @@
 	_printf_(true,"\n");
 }
+
