--- MITgcm_contrib/mitgcm_tools/mitgcmhistory.m 2007/12/10 05:28:50 1.3 +++ MITgcm_contrib/mitgcm_tools/mitgcmhistory.m 2007/12/12 23:42:46 1.4 @@ -22,7 +22,6 @@ eval(['!grep ' varargin{k} ' ' file ' | sed s/.\*=// | sed s/NAN/1.23456789/ > ' tfile]) % 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. @@ -32,7 +31,24 @@ lngt=length(vals(:,k)); else tmp=textread(tfile,'%f'); - % allow + if abs(length(tmp)-lngt)>1 + % try to read one line at a time in order to deal with special case + % of values like, e.g.: " -2.9248686233802-321" + fid=fopen(tfile); + n=0; + while(~feof(fid)) + n=n+1; + tmp2=fgetl(fid); + val=sscanf(tmp2,'%f'); + if length(val)>1 + tmp(n)=0; + else + tmp(n)=val; + end + end + fid=fclose(fid); + tmp=tmp(1:n); + end if abs(length(tmp)-lngt)>1 error(sprintf('An error occured while scanning for: %s',varargin{k})); else