Index: /issm/trunk/src/m/solutions/cielo/SpawnCore.m
===================================================================
--- /issm/trunk/src/m/solutions/cielo/SpawnCore.m	(revision 962)
+++ /issm/trunk/src/m/solutions/cielo/SpawnCore.m	(revision 963)
@@ -53,4 +53,7 @@
 end
 
+%process results
+results=processresults(models,results);
+
 %now process the results to get response function values
 responses=zeros(numel(responsedescriptors),1);
@@ -59,3 +62,2 @@
 	responses(i)=qmuresponse(models,results,descriptor);
 end
-
Index: /issm/trunk/src/m/solutions/cielo/diagnostic.m
===================================================================
--- /issm/trunk/src/m/solutions/cielo/diagnostic.m	(revision 962)
+++ /issm/trunk/src/m/solutions/cielo/diagnostic.m	(revision 963)
@@ -36,4 +36,7 @@
 		%launch core of diagnostic solution.
 		results=diagnostic_core(models,inputs);
+	
+		%process results
+		md.results.diagnostic=processresults(models,results);
 	else
 		%launch dakota driver for diagnostic core solution
@@ -41,6 +44,4 @@
 	end
 
-	md.results.diagnostic=processresults(models,results);
-
 	%stop timing
 	t2=clock;
Index: /issm/trunk/src/m/solutions/dakota/dakota_out_parse.m
===================================================================
--- /issm/trunk/src/m/solutions/dakota/dakota_out_parse.m	(revision 962)
+++ /issm/trunk/src/m/solutions/dakota/dakota_out_parse.m	(revision 963)
@@ -183,12 +183,12 @@
 %  draw box plot
 
-figure
-subplot(2,1,1)
-plot_boxplot(dresp);
+%figure
+%subplot(2,1,1)
+%plot_boxplot(dresp);
 
 %  draw normal probability plot
 
-subplot(2,1,2)
-plot_normplot(dresp);
+%subplot(2,1,2)
+%plot_normplot(dresp);
 
 end
Index: /issm/trunk/src/m/solutions/dakota/postqmu.m
===================================================================
--- /issm/trunk/src/m/solutions/dakota/postqmu.m	(revision 963)
+++ /issm/trunk/src/m/solutions/dakota/postqmu.m	(revision 963)
@@ -0,0 +1,62 @@
+function md=postqmu(md)
+
+%INPUT function md=postqmu(md,qmufile,qmudir)
+%Deal with dakota output results in files.
+
+global ISSM_DIR;
+
+%  check to see if dakota returned errors in the err file
+qmuerrfile=[md.name '.qmu.err'];
+
+if exist(qmuerrfile,'file')
+   fide=fopen(qmuerrfile,'r');
+   fline=fgetl(fide);
+   if ischar(fline)
+       while ischar(fline)
+           disp(sprintf('%s',fline));
+           fline=fgetl(fide);
+       end
+       status=fclose(fide);
+       cd ../
+       error(['Dakota returned error in ''' qmuerrfile ' file.  ''' qmudir ''' directory retained.'])
+    end
+    status=fclose(fide);
+else
+   cd ../
+   error(['Dakota did not generate ''' qmuerrfile ' file.  ''' qmudir ''' directory retained.'])
+end
+
+%parse inputs and results from dakota
+qmuinfile=[md.name '.qmu.in'];
+qmuoutfile=[md.name '.qmu.out'];
+
+[method,dvar,dresp_in]=dakota_in_parse(qmuinfile);
+md.dakotaresults.method   =method;
+md.dakotaresults.dvar     =dvar;
+md.dakotaresults.dresp_in =dresp_in;
+
+[method,dresp_out,scm,pcm,srcm,prcm]=dakota_out_parse(qmuoutfile);
+md.dakotaresults.dresp_out=dresp_out;
+md.dakotaresults.scm      =scm;
+md.dakotaresults.pcm      =pcm;
+md.dakotaresults.srcm     =srcm;
+md.dakotaresults.prcm     =prcm;
+
+if exist('dakota_tabular.dat','file')
+    [method,dresp_dat                  ]=dakota_out_parse('dakota_tabular.dat');
+    md.dakotaresults.dresp_dat=dresp_dat;
+end
+
+%save input and output files into model
+%md.dakotain =readfile([qmufile '.in']);
+%md.dakotaout=readfile([qmufile '.out']);
+%if exist('dakota_tabular.dat','file')
+%	md.dakotadat=readfile('dakota_tabular.dat');
+%end
+
+%  move all the individual function evalutations into zip files
+if ~md.qmu_analysis,
+	system('zip -mq params.in.zip params.in.[1-9]*');
+	system('zip -mq results.out.zip results.out.[1-9]*');
+	system('zip -mq matlab.out.zip matlab*.out.[1-9]*');
+end
Index: /issm/trunk/src/m/solutions/dakota/preqmu.m
===================================================================
--- /issm/trunk/src/m/solutions/dakota/preqmu.m	(revision 963)
+++ /issm/trunk/src/m/solutions/dakota/preqmu.m	(revision 963)
@@ -0,0 +1,115 @@
+function md=preqmu(md,options)
+%QMU - apply Quantification of Margins and Uncertainties techniques 
+%      to a solution sequence (like diagnostic.m, progonstic.m, etc ...), 
+%      using the Dakota software from Sandia.
+%
+%   options come from the solve.m routine. They can include Dakota options:
+%
+%       qmudir:  any directory where to run the qmu analysis
+%       qmufile: input file for Dakota
+%       ivar: selection number for variables input (if several are specified in variables)
+%       iresp: same thing for response functions
+%       imethod: same thing for methods
+%       iparams: same thing for params
+%       overwrite: overwrite qmudir
+%       outfiles: (John?)
+%       rstfile: backup file name
+%       rundakota: (John?)
+%       runmpi: (John?)
+
+global ISSM_DIR;
+
+displaystring(md.debug,'\n%s\n','preprocessing dakota inputs');
+
+%recover some fields
+package=options.package;
+
+%first create temporary directory in which we will work
+if exist(options.qmudir,'dir')
+    if ~isfield(options,'overwrite')
+        options.overwrite=input(['Overwrite existing ''' options.qmudir ''' directory? Y/N [N]: '], 's');
+    end
+    if strncmpi(options.overwrite,'y',1)
+        system(['rm -rf ' options.qmudir]);
+%    else
+%        error('Existing ''%s'' directory not overwritten.',qmudir);
+    end
+end
+mkdir(options.qmudir)
+cd(options.qmudir)
+
+%when running in library mode, the in file needs to be called md.name.qmu.in
+options.qmufile=[md.name ];
+
+%create m and in files for dakota
+if (~isfield(md.qmu_params(options.iparams),'direct') || ...
+    ~md.qmu_params(options.iparams).direct) && ...
+   (~isfield(md.qmu_params(options.iparams),'analysis_driver') || ...
+    isempty(md.qmu_params(options.iparams).analysis_driver))
+    md.qmu_params(options.iparams).analysis_driver=[ISSM_DIR '/src/m/solutions/dakota/cielo_ice_script.sh'];
+end
+
+%retrieve variables and resposnes for this particular analysis.
+variables=md.variables(options.ivar);
+responses=md.responses(options.iresp);
+
+%create m and in files for dakota
+dakota_in_data(md.qmu_method(options.imethod),variables,md.responses,md.qmu_params(options.iparams),options.qmufile,package,md);
+
+
+%in library mode, we only need the dakota in file
+system(['rm -rf ' md.name '.m']);
+
+%figure out number of variables and responses, it's not straightforwared
+numvariables=0;
+variable_fieldnames=fieldnames(variables);
+for i=1:length(variable_fieldnames),
+	field_name=variable_fieldnames{i};
+	fieldvariables=variables.(field_name);
+	numvariables=numvariables+numel(variables.(field_name));
+end
+
+numresponses=0;
+response_fieldnames=fieldnames(responses);
+for i=1:length(response_fieldnames),
+	field_name=response_fieldnames{i};
+	fieldresponses=responses.(field_name);
+	numresponses=numresponses+numel(responses.(field_name));
+end
+
+%ok, now, for this particular qmu analysis, iresp and ivar specifiy the variables and responses. 
+%The Qmu module will need a list of variable descriptors and response descriptors. 
+%For ease of use, we gather this list here.
+
+count=0;
+variable_fieldnames=fieldnames(variables);
+variabledescriptors={};
+for i=1:length(variable_fieldnames),
+	field_name=variable_fieldnames{i};
+	fieldvariables=variables.(field_name);
+	for j=1:length(fieldvariables),
+		descriptor=fieldvariables(j).descriptor;
+		variabledescriptors{end+1}=descriptor;
+		count=count+1;
+	end
+end
+
+count=0;
+response_fieldnames=fieldnames(responses);
+responsedescriptors={};
+for i=1:length(response_fieldnames),
+	field_name=response_fieldnames{i};
+	fieldresponses=responses.(field_name);
+	for j=1:length(fieldresponses),
+		descriptor=fieldresponses(j).descriptor;
+		responsedescriptors{end+1}=descriptor;
+		count=count+1;
+	end
+end
+
+%register the fields that will be needed by the Qmu model.
+md.numberofvariables=numvariables;
+md.numberofresponses=numresponses;
+md.variabledescriptors=variabledescriptors;
+md.responsedescriptors=responsedescriptors;
+
Index: sm/trunk/src/m/solutions/dakota/qmu.m
===================================================================
--- /issm/trunk/src/m/solutions/dakota/qmu.m	(revision 962)
+++ 	(revision )
@@ -1,204 +1,0 @@
-function md=qmu(md,varargin)
-%QMU - apply Quantification of Margins and Uncertainties techniques 
-%      to a solution sequence (like diagnostic.m, progonstic.m, etc ...), 
-%      using the Dakota software from Sandia.
-%   Usage:
-%      md=qmu(md,varargin)
-%      where varargin is a lit of paired arguments. 
-%      arguments can be: 'analysis_type': 'diagnostic','thermal','prognostic','transient'
-%      arguments can be: 'sub_analysis_type': 'transient','steady','' (default if empty = 'steady')
-%      arguments can be: 'package': 'macayeal','ice','cielo' (default if not specified = 'cielo')
-%
-%
-%   Examples:
-%      md=qmu(md,'analysis_type','diagnostic','package','cielo');
-%      md=qmu(md,'analysis_type','control','package','ice');
-%      md=qmu(md,'analysis_type','thermal','sub_analysis_type','transient','package','ice');
-%      md=qmu(md,'analysis_type','thermal','sub_analysis_type','steady','package','cielo');
-%      md=qmu(md,'analysis_type','thermal','package','cielo');
-%
-%   On top of these solution arguments (found also in solve.m), user can specify QMU 
-%   specific arguments: 
-%
-%       qmudir:  any directory where to run the qmu analysis
-%       qmufile: input file for Dakota
-%       ivar: selection number for variables input (if several are specified in variables)
-%       iresp: same thing for response functions
-%       imethod: same thing for methods
-%       iparams: same thing for params
-%       overwrite: overwrite qmudir
-%       outfiles: (John?)
-%       rstfile: backup file name
-%       rundakota: (John?)
-%       runmpi: (John?)
-
-%some checks on list of arguments
-global ISSM_DIR;
-
-%recover options
-options=recover_qmu_options(md,varargin{:});
-
-%add default options
-options=process_qmu_options(options);
-
-%recover some fields
-md.analysis_type=options.analysis_type;
-md.sub_analysis_type=options.sub_analysis_type;
-package=options.package;
-
-%Use package to set solution namespace
-usenamespace(package);
-
-if ~ismodelselfconsistent(md,package),
-	error(' '); %previous error messages should explain what is going on.
-end
-
-displaystring(md.debug,'\n%s\n','launching solution sequence');
-
-
-%first create temporary directory in which we will work
-if exist(options.qmudir,'dir')
-    if ~isfield(options,'overwrite')
-        options.overwrite=input(['Overwrite existing ''' options.qmudir ''' directory? Y/N [N]: '], 's');
-    end
-    if strncmpi(options.overwrite,'y',1)
-        system(['rm -rf ' options.qmudir]);
-%    else
-%        error('Existing ''%s'' directory not overwritten.',qmudir);
-    end
-end
-mkdir(options.qmudir)
-cd(options.qmudir)
-
-%some data needs to be copied in qmudir when not running in library mode
-if ~md.dakotaplugin,
-	system('cp $ISSM_DIR/startup.m .');
-
-	%save our model in qmu so that it can be repeatedly used by Dakota.
-	save('Qmu.model','md')
-end
-
-%when running in library mode, the in file needs to be called md.name.qmu.in
-if md.dakotaplugin,
-	options.qmufile=[md.name ];
-end
-
-%create m and in files for dakota
-if (~isfield(md.qmu_params(options.iparams),'direct') || ...
-    ~md.qmu_params(options.iparams).direct) && ...
-   (~isfield(md.qmu_params(options.iparams),'analysis_driver') || ...
-    isempty(md.qmu_params(options.iparams).analysis_driver))
-    md.qmu_params(options.iparams).analysis_driver=[ISSM_DIR '/src/m/solutions/dakota/cielo_ice_script.sh'];
-end
-
-%create m and in files for dakota
-dakota_in_data(md.qmu_method(options.imethod),md.variables(options.ivar),md.responses(options.iresp),md.qmu_params(options.iparams),options.qmufile,package,md);
-
-
-%in library mode, we only need the dakota in file
-if md.dakotaplugin,
-	system(['rm -rf ' md.name '.m']);
-end
-
-%Dakota can be run in library mode in parallel, or using the 
-%standard Dakota (scripted or direct) interface. Those two 
-%modes of running are very different, and call for different 
-%solution sequences. We branch here. 
-
-if md.dakotaplugin,
-
-	%Check we are running in parallel.
-	if strcmpi(md.cluster,'none'),
-		error('qmu error message: cannot run in library mode serially! set dakotaplugin to 0');
-	end
-
-	%Get cluster.rc location
-	cluster_rc_location=which('cluster.rc');
-
-	%let solution sequences know that we are running in qmu mode
-	md.qmu_analysis=1;
-
-	%Figure out parameters for this particular cluster
-	[codepath,executionpath]=ClusterParameters(md.cluster,cluster_rc_location);
-
-	%Marshall model data into a binary file.
-	marshall(md);
-
-	%add qmu fields to binary file
-	qmumarshall(md,md.variables(options.ivar),md.responses(options.iresp));
-
-	%Now, we need to build the queuing script, used by the cluster to launch the job.
-	BuildQueueingScript(md,executionpath,codepath);
-
-	%Now, launch the queueing script
-	LaunchQueueJob(md,executionpath);
-
-	%Do we return, or just wait for results?
-	if md.waitonlock,
-		%we wait for the done file
-		waitonlock([executionpath '/' md.name '.lock']);
-		%load results
-		md=loadresultsfromcluster(md);
-	else
-		return;
-	end
-	
-else
-%  check for existence of results.out files to use
-	if exist('results.out.1','file') || exist('results.out.zip','file')
-		if ~isfield(options,'outfiles')
-			options.outfiles=input(['Use existing ''results.out'' files? Y/N [N]: '], 's');
-		end
-		if ~strncmpi(options.outfiles,'y',1)
-			system('rm -f results.out.[1-9]*');
-		else
-			if exist('results.out.zip','file') && ~exist('results.out.1','file')
-				display('Inflating ''results.out.zip'' file.');
-				system('unzip -q results.out.zip');
-			end
-		end
-	end
-
-	%  check for existence of dakota.rst file to use
-	rstflag='';
-	if (~isfield(options,'outfiles') || ~strncmpi(options.outfiles,'y',1)) && ...
-		exist('dakota.rst','file')
-		if ~isfield(options,'rstfile')
-			options.rstfiles=input(['Use existing ''dakota.rst'' file? Y/N [N]: '], 's');
-		end
-		if strncmpi(options.rstfiles,'y',1)
-			system('rm -f results.out.[1-9]*');
-			system('dakota_restart_util print dakota.rst | grep completed');
-			rstflag=' -read_restart dakota.rst';
-		end
-	end
-
-	%call dakota
-	if ~isfield(options,'rundakota')
-		options.rundakota=input(['Run Dakota analysis ''' qmufile '''? Y/N [N]: '], 's');
-	end
-	if ~strncmpi(options.rundakota,'y',1)
-		cd ..
-		return
-	end
-
-	if ~options.runmpi
-		system(['dakota -i ' qmufile '.in -o ' qmufile '.out -e ' qmufile '.err' rstflag]);
-	else
-	%  use 'mpd --ncpus=8 &' to initialize mpi and 'mpdringtest' to verify.
-	%  exporting MPIRUN_NPROCS sets mpi in dakota.
-	%    system('mpd --ncpus=8 &');
-	%    system('mpdringtest');
-		system(['export MPIRUN_NPROCS=8;mpirun -np 4 dakota -i ' qmufile '.in -o ' qmufile '.out -e ' qmufile '.err' rstflag]);
-	end
-
-end
-
-
-
-%Now load the results from dakota output files.
-qmuoutput(md,options.qmufile,options.qmudir);
-
-%Get out of qmu directory
-cd ..
-
Index: /issm/trunk/src/m/solutions/dakota/qmuisdistributed.m
===================================================================
--- /issm/trunk/src/m/solutions/dakota/qmuisdistributed.m	(revision 963)
+++ /issm/trunk/src/m/solutions/dakota/qmuisdistributed.m	(revision 963)
@@ -0,0 +1,11 @@
+function found=qmuisdistribted(string)
+%QMUISDISTRIBTED - figure out if a string is a decriptor with a numerical postfix. Like thickness1, or drag10
+
+found=0;
+for i=1:length(string),
+	if ~isempty(str2num(string(i))),
+		found=1;
+		break;
+	end
+end
+
Index: /issm/trunk/src/m/solutions/dakota/qmumarshall.m
===================================================================
--- /issm/trunk/src/m/solutions/dakota/qmumarshall.m	(revision 962)
+++ /issm/trunk/src/m/solutions/dakota/qmumarshall.m	(revision 963)
@@ -71,4 +71,8 @@
 %write npart to disk
 WriteData(fid,md.npart,'Integer','npart');
+
+%write ivar and iresp to disk
+WriteData(fid,md.ivar,'Integer','ivar');
+WriteData(fid,md.iresp,'Integer','iresp');
 	
 %close file
Index: sm/trunk/src/m/solutions/dakota/qmuoutput.m
===================================================================
--- /issm/trunk/src/m/solutions/dakota/qmuoutput.m	(revision 962)
+++ 	(revision )
@@ -1,69 +1,0 @@
-function md=qmuoutput(md,qmufile,qmudir);
-
-%INPUT function md=qmuoutput(md,qmufile,qmudir)
-%Deal with dakota output results in files.
-
-global ISSM_DIR;
-
-%  check to see if dakota returned errors in the err file
-qmuerrfile=[qmufile '.err'];
-if md.qmu_analysis,
-	qmuerrfile=[qmufile '.qmu.err'];
-end
-
-if exist(qmuerrfile,'file')
-   fide=fopen(qmuerrfile,'r');
-   fline=fgetl(fide);
-   if ischar(fline)
-       while ischar(fline)
-           disp(sprintf('%s',fline));
-           fline=fgetl(fide);
-       end
-       status=fclose(fide);
-       cd ../
-       error(['Dakota returned error in ''' qmuerrfile ' file.  ''' qmudir ''' directory retained.'])
-    end
-    status=fclose(fide);
-else
-   cd ../
-   error(['Dakota did not generate ''' qmuerrfile ' file.  ''' qmudir ''' directory retained.'])
-end
-
-%parse inputs and results from dakota
-qmuinfile=[qmufile '.in'];
-qmuoutfile=[qmufile '.out'];
-if md.qmu_analysis,
-	qmuinfile=[qmufile '.qmu.in'];
-	qmuoutfile=[qmufile '.qmu.out'];
-end
-
-[method,dvar,dresp_in]=dakota_in_parse(qmuinfile);
-md.dakotaresults.method   =method;
-md.dakotaresults.dvar     =dvar;
-md.dakotaresults.dresp_in =dresp_in;
-
-[method,dresp_out,scm,pcm,srcm,prcm]=dakota_out_parse(qmuoutfile);
-md.dakotaresults.dresp_out=dresp_out;
-md.dakotaresults.scm      =scm;
-md.dakotaresults.pcm      =pcm;
-md.dakotaresults.srcm     =srcm;
-md.dakotaresults.prcm     =prcm;
-
-if exist('dakota_tabular.dat','file')
-    [method,dresp_dat                  ]=dakota_out_parse('dakota_tabular.dat');
-    md.dakotaresults.dresp_dat=dresp_dat;
-end
-
-%save input and output files into model
-%md.dakotain =readfile([qmufile '.in']);
-%md.dakotaout=readfile([qmufile '.out']);
-%if exist('dakota_tabular.dat','file')
-%	md.dakotadat=readfile('dakota_tabular.dat');
-%end
-
-%  move all the individual function evalutations into zip files
-if ~md.qmu_analysis,
-	system('zip -mq params.in.zip params.in.[1-9]*');
-	system('zip -mq results.out.zip results.out.[1-9]*');
-	system('zip -mq matlab.out.zip matlab*.out.[1-9]*');
-end
Index: /issm/trunk/src/m/solutions/dakota/qmuresponse.m
===================================================================
--- /issm/trunk/src/m/solutions/dakota/qmuresponse.m	(revision 963)
+++ /issm/trunk/src/m/solutions/dakota/qmuresponse.m	(revision 963)
@@ -0,0 +1,8 @@
+function response=qmuresponse(models,results,descriptor)
+%QMURESPONSE - compute response function from model results.
+
+if strcmpi(descriptor,'max_vel'),
+	response=max(results.vel);
+else
+	error(['qmuresponse error message: unknow descriptor ' descriptor]);
+end
Index: /issm/trunk/src/m/solutions/dakota/qmuroot.m
===================================================================
--- /issm/trunk/src/m/solutions/dakota/qmuroot.m	(revision 963)
+++ /issm/trunk/src/m/solutions/dakota/qmuroot.m	(revision 963)
@@ -0,0 +1,13 @@
+function root=qmuroot(string)
+%QMUROOT - return root of a distributed descriptor
+
+root='';
+found=0;
+for i=1:length(string),
+	if ~isempty(str2num(string(i))),
+		break;
+	else
+		root=[root string(i)];
+	end
+end
+
