--- MITgcm_contrib/mitgcm_tools/mitgcmhistory.m 2007/12/02 05:45:51 1.2 +++ MITgcm_contrib/mitgcm_tools/mitgcmhistory.m 2007/12/10 05:28:50 1.3 @@ -20,10 +20,31 @@ for k=1:nargin-1; try eval(['!grep ' varargin{k} ' ' file ' | sed s/.\*=// | sed s/NAN/1.23456789/ > ' tfile]) - vals(:,k)=textread(tfile,'%f'); + + % vals(:,k)=textread(tfile,'%f'); + + % When output file is from an ongoing integration, one or more of + % the diagnostics may be missing at the last available time step. + % The code below accomodates this difference in length. + + if k==1 + vals(:,k)=textread(tfile,'%f'); + lngt=length(vals(:,k)); + else + tmp=textread(tfile,'%f'); + % allow + if abs(length(tmp)-lngt)>1 + error(sprintf('An error occured while scanning for: %s',varargin{k})); + else + lngt=min(lngt,length(tmp)); + vals(1:lngt,k)=tmp(1:lngt); + end + + end delete(tfile) catch delete(tfile) error(sprintf('An error occured while scanning for: %s',varargin{k})); end end +vals=vals(1:lngt,:);