Index: /issm/trunk/src/m/solutions/dakota/dakota_out_parse.m
===================================================================
--- /issm/trunk/src/m/solutions/dakota/dakota_out_parse.m	(revision 645)
+++ /issm/trunk/src/m/solutions/dakota/dakota_out_parse.m	(revision 646)
@@ -16,5 +16,5 @@
 fidi=fopen(sprintf('%s',filei),'r');
 if (fidi < 0)
-    error('%s could not be opened.',filei);
+    error('''%s'' could not be opened.',filei);
 end
 
@@ -25,5 +25,5 @@
 if ~ischar(fline)
     ieof=1;
-    error('File %s is empty.',filei);
+    error('File ''%s'' is empty.',filei);
 end
 
@@ -42,4 +42,5 @@
     return
 end
+% display(['  ' deblank(fline)]);
 
 [ntokens,tokens]=fltokens(fline);
@@ -47,4 +48,5 @@
 display(sprintf('Dakota method=%s.',method));
 
+dresp=struct([]);
 scm =struct([]);
 pcm =struct([]);
@@ -52,31 +54,50 @@
 prcm=struct([]);
 
-%%  switch according to the Dakota method
-
-switch lower(method)
-%     case {'dot_bfgs','dot_frcg','dot_mmfd','dot_slp','dot_sqp'}
-%     case {'npsol_sqp'}
-    case {'conmin_frcg','conmin_mfd'}
-        [dresp]=opt_any(fidi);
-%     case {'optpp_cg','optpp_q_newton','optpp_fd_newton',...
-%             'optpp_newton','optpp_pds'}
-%     case {'asynch_pattern_search'}
-%     case {'coliny_cobyla','coliny_direct','coliny_ea',...
-%             'coliny_pattern_search','coliny_solis_wets'}
-%     case {'ncsu_direct'}
-%     case {'moga','soga'}
-%     case {'nl2sol','nlssol_sqp','optpp_g_newton'}
-    case {'nond_sampling'}
-        [dresp,scm,pcm,srcm,prcm]=nond_samp(fidi);
-    case {'nond_local_reliability'}
-        [dresp]=nond_locrel(fidi);
-     case {'dace','fsu_quasi_mc','fsu_cvt'}
-        [dresp]=param_any(fidi);
-     case {'vector_parameter_study','list_parameter_study',...
-             'centered_parameter_study','multidim_parameter_study'}
-        [dresp]=param_any(fidi);
-    otherwise
-        error('Unrecognized  method ''%s'' in file %s.',...
-            method,filei);
+%%  loop through the file to find the iterator completion
+
+[fline]=findline(fidi,['<<<<< Iterator ' method ' completed.']);
+if ~ischar(fline)
+    return
+end
+% display(['  ' deblank(fline)]);
+
+fline=fgetl(fidi);
+
+%%  process each results section based on content of the file
+
+while ischar(fline)
+%     ipos=ftell(fidi);
+    if     strncmp(fline,'<<<<< Function evaluation summary',33)
+        [nfeval]=nfeval_read(fidi,fline);
+    elseif strncmp(fline,'Statistics based on ',20)
+        [nsamp]=nsamp_read(fidi,fline);
+    elseif strncmp(fline,'Moments for each response function',34)
+        [dresp]=moments_read(fidi,dresp,fline);
+    elseif strncmp(fline,'95% confidence intervals for each response function',51)
+        [dresp]=cis_read(fidi,dresp,fline);
+    elseif strncmp(fline,'Probabilities for each response function',40)
+        [dresp]=cdfs_read(fidi,dresp,fline);
+    elseif strncmp(fline,'Simple Correlation Matrix',25)
+        [scm]=corrmat_read(fidi,'Simple Correlation Matrix',fline);
+    elseif strncmp(fline,'Partial Correlation Matrix',26)
+        [pcm]=corrmat_read(fidi,'Partial Correlation Matrix',fline);
+    elseif strncmp(fline,'Simple Rank Correlation Matrix',30)
+        [srcm]=corrmat_read(fidi,'Simple Rank Correlation Matrix',fline);
+    elseif strncmp(fline,'Partial Rank Correlation Matrix',31)
+        [prcm]=corrmat_read(fidi,'Partial Rank Correlation Matrix',fline);
+    elseif strncmp(fline,'MV Statistics for ',18)
+        [dresp]=mvstats_read(fidi,dresp,fline);
+    elseif strncmp(fline,'<<<<< Best ',11)
+        [dresp]=best_read(fidi,dresp,fline);
+    elseif strncmp(fline,'The following lists volumetric uniformity measures',50)
+        [dresp]=vum_read(fidi,dresp,fline);
+    elseif strncmp(fline,'-----',5)
+    elseif isempty(fline)
+    else
+        display(['Unexpected line: ' deblank(fline)]);
+        fline=fgetl(fidi);
+    end
+    fline=fgetl(fidi);
+%     fseek(fidi,ipos,'bof');
 end
 
@@ -173,43 +194,18 @@
 end
 
-%%  function to parse the nond_sampling output file
-
-function [dresp,scm,pcm,srcm,prcm]=nond_samp(fidi)
-
-%  loop through the file to find the number of function evaluations
-
-[nfeval]=nfeval_read(fidi);
-
-%  loop through the file to find the number of samples
-
-[nsamp]=nsamp_read(fidi);
-
-%  loop through the file to find the moments
-
-[dresp]=moments_read(fidi,struct([]));
-
-%  loop through the file to find the confidence intervals
-
-[dresp]=cis_read(fidi,dresp);
-
-%  loop through the file to find the probabilities
-
-[dresp]=cdfs_read(fidi,dresp);
-
-%  loop through the file to find the scm
-
-[scm]=corrmat_read(fidi,'Simple Correlation Matrix');
-
-%  loop through the file to find the pcm
-
-[pcm]=corrmat_read(fidi,'Partial Correlation Matrix');
-
-%  loop through the file to find the srcm
-
-[srcm]=corrmat_read(fidi,'Simple Rank Correlation Matrix');
-
-%  loop through the file to find the prcm
-
-[prcm]=corrmat_read(fidi,'Partial Rank Correlation Matrix');
+%%  function to find and read the number of function evaluations
+
+function [nfeval]=nfeval_read(fidi,fline)
+
+if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
+    [fline]=findline(fidi,'<<<<< Function evaluation summary');
+    if ~ischar(fline)
+        return
+    end
+end
+
+[ntokens,tokens]=fltokens(fline);
+nfeval=tokens{1}{5};
+display(sprintf('  Dakota function evaluations=%d.',nfeval));
 
 end
@@ -217,9 +213,11 @@
 %%  function to find and read the number of samples
 
-function [nsamp]=nsamp_read(fidi)
-
-[fline]=findline(fidi,'Statistics based on ');
-if ~ischar(fline)
-    return
+function [nsamp]=nsamp_read(fidi,fline)
+
+if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
+    [fline]=findline(fidi,'Statistics based on ');
+    if ~ischar(fline)
+        return
+    end
 end
 
@@ -232,9 +230,11 @@
 %%  function to find and read the moments
 
-function [dresp]=moments_read(fidi,dresp)
-
-[fline]=findline(fidi,'Moments for each response function');
-if ~ischar(fline)
-    return
+function [dresp]=moments_read(fidi,dresp,fline)
+
+if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
+    [fline]=findline(fidi,'Moments for each response function');
+    if ~ischar(fline)
+        return
+    end
 end
 
@@ -264,10 +264,12 @@
 %%  function to find and read the confidence intervals
 
-function [dresp]=cis_read(fidi,dresp)
-
-[fline]=findline(fidi,...
-    '95% confidence intervals for each response function');
-if ~ischar(fline)
-    return
+function [dresp]=cis_read(fidi,dresp,fline)
+
+if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
+    [fline]=findline(fidi,...
+        '95% confidence intervals for each response function');
+    if ~ischar(fline)
+        return
+    end
 end
 
@@ -311,9 +313,11 @@
 %%  function to find and read the cdf's
 
-function [dresp]=cdfs_read(fidi,dresp)
-
-[fline]=findline(fidi,'Probabilities for each response function');
-if ~ischar(fline)
-    return
+function [dresp]=cdfs_read(fidi,dresp,fline)
+
+if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
+    [fline]=findline(fidi,'Probabilities for each response function');
+    if ~ischar(fline)
+        return
+    end
 end
 
@@ -380,10 +384,12 @@
 %%  function to find and read a correlation matrix
 
-function [cmat]=corrmat_read(fidi,cmstr)
-
-[fline]=findline(fidi,cmstr);
-if ~ischar(fline)
-    cmat=struct([]);
-    return
+function [cmat]=corrmat_read(fidi,cmstr,fline)
+
+if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
+    [fline]=findline(fidi,cmstr);
+    if ~ischar(fline)
+        cmat=struct([]);
+        return
+    end
 end
 
@@ -434,44 +440,16 @@
 end
 
-%%  function to parse the nond_local_reliability output file
-
-function [dresp]=nond_locrel(fidi)
-
-%  loop through the file to find the number of function evaluations
-
-[nfeval]=nfeval_read(fidi);
-
-%  loop through the file to find the statistics
-
-[dresp]=mvstats_read(fidi,struct([]));
-
-end
-
-%%  function to find and read the number of function evaluations
-
-function [nfeval]=nfeval_read(fidi)
-
-[fline]=findline(fidi,'<<<<< Function evaluation summary');
-if ~ischar(fline)
-    return
-end
-
-[ntokens,tokens]=fltokens(fline);
-nfeval=tokens{1}{5};
-display(sprintf('  Dakota function evaluations=%d.',nfeval));
-
-end
-
 %%  function to find and read the MV statistics
 
-function [dresp]=mvstats_read(fidi,dresp)
+function [dresp]=mvstats_read(fidi,dresp,fline)
+
+if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
+    [fline]=findline(fidi,'MV Statistics for ');
+    if ~ischar(fline)
+        return
+    end
+end
 
 ieof=0;
-
-[fline]=findline(fidi,'MV Statistics for ');
-if ~ischar(fline)
-    return
-end
-
 display('Reading MV statistics for response functions:');
 ndresp=0;
@@ -605,36 +583,18 @@
 end
 
-%%  function to parse any optimization output file
-
-function [dresp]=opt_any(fidi)
-
-%%  search through the file to find the Dakota output data
-
-[fline]=findline(fidi,'<<<<< Iterator');
-if ~ischar(fline)
-    return
-end
-display(['  ' deblank(fline)]);
-
-%  loop through the file to find the number of function evaluations
-
-[nfeval]=nfeval_read(fidi);
-
-%  loop through the file to find the best evaluation
-
-[dresp]=best_read(fidi,struct([]));
-
-end
-
 %%  function to find and read the best evaluation
 
-function [dresp]=best_read(fidi,dresp)
-
-[fline]=findline(fidi,'<<<<< Best ');
-if ~ischar(fline)
-    return
-end
-dresp(end+1).best=[];
-
+function [dresp]=best_read(fidi,dresp,fline)
+
+if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
+    [fline]=findline(fidi,'<<<<< Best ');
+    if ~ischar(fline)
+        return
+    end
+end
+
+if isempty(dresp)
+    dresp(end+1).best=[];
+end
 display('Reading values for best function evaluation:');
 
@@ -737,36 +697,18 @@
 end
 
-%%  function to parse any parameter study output file
-
-function [dresp]=param_any(fidi)
-
-%%  search through the file to find the Dakota output data
-
-[fline]=findline(fidi,'<<<<< Iterator');
-if ~ischar(fline)
-    return
-end
-display(['  ' deblank(fline)]);
-
-%  loop through the file to find the number of function evaluations
-
-[nfeval]=nfeval_read(fidi);
-
-%  loop through the file to find the volumetric uniformity measures
-
-[dresp]=vum_read(fidi,struct([]));
-
-end
-
 %%  function to find and read the volumetric uniformity measures
 
-function [dresp]=vum_read(fidi,dresp)
-
-[fline]=findline(fidi,'The following lists volumetric uniformity measures');
-if ~ischar(fline)
-    return
-end
-dresp(end+1).vum=[];
-
+function [dresp]=vum_read(fidi,dresp,fline)
+
+if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
+    [fline]=findline(fidi,'The following lists volumetric uniformity measures');
+    if ~ischar(fline)
+        return
+    end
+end
+
+if isempty(dresp)
+    dresp(end+1).vum=[];
+end
 display('Reading measures for volumetric uniformity.');
 
