/[MITgcm]/MITgcm_contrib/high_res_cube/matlab-grid-generator/bin/grepread.m
ViewVC logotype

Contents of /MITgcm_contrib/high_res_cube/matlab-grid-generator/bin/grepread.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Nov 11 18:08:08 2003 UTC (21 years, 8 months ago) by cnh
Branch: MAIN, initial
CVS Tags: baseline, HEAD
Changes since 1.1: +0 -0 lines
Checking in work done with Dimitri on high-resolution cube gridding and parallel 
communications. 
   o code is in a contrib experiment for now so we can continue collaborating
     on it. However most code is general and will be moved into main branch once 
     it is fully hardened.
   o There are README files in the contrib root and in the subdirectories that
     explain the contents

1 function [vals] = grepread(file,varargin)
2 % VALS = GREPREAD(FILE,EXPR1,...);
3 %
4 % Extracts the expressions "expr1","expr2",... from the file "file".
5 % This assumes output in the standard form defined by the MITgcm
6 % monitor package and is not a replacement for TEXTREAD.
7 %
8 % e.g.
9 % >> vals=grepread('output.txt','time_secondsf','ke_mean','ke_max');
10 % >> plot(vals(:,1)/86400,vals(:,2:3));
11
12 if nargin<2
13 error('You must supply a filename and at least one search expression!')
14 end
15
16 tfile=sprintf('/tmp/grepexpr%15.15f',rand);
17 for k=1:nargin-1;
18 try
19 eval(['!grep ' varargin{k} ' ' file ' | sed s/.\*=// | sed s/NAN/1.23456789/ >! ' tfile])
20 vals(:,k)=textread(tfile,'%f');
21 delete(tfile)
22 catch
23 delete(tfile)
24 error(sprintf('An error occured while scanning for: %s',varargin{k}));
25 end
26 end

  ViewVC Help
Powered by ViewVC 1.1.22