Index: /issm/trunk-jpl/src/m/contrib/paraview/exportVTK.m
===================================================================
--- /issm/trunk-jpl/src/m/contrib/paraview/exportVTK.m	(revision 16489)
+++ /issm/trunk-jpl/src/m/contrib/paraview/exportVTK.m	(revision 16490)
@@ -1,3 +1,3 @@
-function exportVTK(filename,model)
+function exportVTK(filename,model,varargin)
 % vtk export
 % function exportVTK(filename,model)
@@ -11,4 +11,8 @@
 %------------------------------------------------------------------
 %        model      this is md 
+%------------------------------------------------------------------
+% By default only the results are exported, you can add whichever
+% field you need as a string:
+% add 'geometry' to export md.geometry
 %
 % Basile de Fleurian:
@@ -35,9 +39,7 @@
 %this is the result structure
 res_struct=model.results;
-
 %Getting all the solutions of the model
 solnames=fields(res_struct);
 num_of_sols=length(solnames);
-
 %building solution structure 
 for i=1:num_of_sols
@@ -48,7 +50,7 @@
 num_of_timesteps=size(sol_struct{1},2);
 
-for i=1:num_of_timesteps;
+for step=1:num_of_timesteps;
 	%by default, we take the timestep from the first solution sturcture
-	timestep=sol_struct{1}(i).step;
+	timestep=sol_struct{1}(step).step;
 	
 	FID = fopen(strcat(path,filesep,name,filesep,name,'.vtk',int2str(timestep),'.vtk'),'w+');
@@ -66,37 +68,51 @@
 	P=[points zeros(num_of_points,3-dim)];
 	fprintf(FID,s,P');
- 
+	
 	fprintf(FID,'CELLS %d %d\n',num_of_elt,num_of_elt*(point_per_elt+1));
 	s='%d';
-	for k=1:point_per_elt
+	for j=1:point_per_elt
 		s=horzcat(s,{' %d'});
   end
 	s=cell2mat(horzcat(s,{'\n'}));
 	fprintf(FID,s,[(point_per_elt)*ones(num_of_elt,1) model.mesh.elements-1]');
- 
+	
 	fprintf(FID,'CELL_TYPES %d\n',num_of_elt);
 	s='%d\n';
 	fprintf(FID,s,celltype*ones(num_of_elt,1));
-	
+	fprintf(FID,'POINT_DATA %s \n',num2str(num_of_points));
+
 	%loop over the different solution structures
 	for j=1:num_of_sols
-
+		
 		%getting the number of fields in the solution
-		fieldnames=fields(sol_struct{j}(i));
+		fieldnames=fields(sol_struct{j}(step));
 		num_of_fields=length(fieldnames);
 		
 		%check which field is a real result and print
-		fprintf(FID,'POINT_DATA %s \n',num2str(num_of_points));
-		for k=1:num_of_fields
-			
-			if ((length(sol_struct{j}(i).(fieldnames{k})))==num_of_points);
+			for k=1:num_of_fields
+			if ((length(sol_struct{j}(step).(fieldnames{k})))==num_of_points);
 				fprintf(FID,'SCALARS %s float 1 \n',fieldnames{k});
 				fprintf(FID,'LOOKUP_TABLE default\n');
 				s='%e\n';
-				fprintf(FID,s,sol_struct{j}(i).(fieldnames{k}));
+				fprintf(FID,s,sol_struct{j}(step).(fieldnames{k}));
+    	end		
+	  end 
+	end
+	
+	%loop on arguments, if something other than result is asked, do
+	%it now
+	for j= 1:nargin-2
+		res_struct=model.(varargin{j});
+		solnames=fields(res_struct);
+		num_of_sols=length(solnames);
+		for k=1:num_of_sols
+			if ((length(res_struct.(solnames{k})))==num_of_points);
+				fprintf(FID,'SCALARS %s float 1 \n',solnames{k});
+				fprintf(FID,'LOOKUP_TABLE default\n');
+				s='%e\n';
+				fprintf(FID,s,res_struct.(solnames{k}));
 	    end		
-     end 
-	 end
-	 fclose(FID);
-  end
+		end 
+	end
+	fclose(FID);
 end
