function [parval] = grepparameter(datafile,str)
%parval=grepparameter(DATAFILE,STRING)
%
%Extracts a parameter value from the input parameter file (e.g. "data") based
%on a parameter name. e.g.
%>> tauxfile=grepparameter(datafile,'zonalwindfile');
%
%Written by adcroft@mit.edu, 2001
%$header

Ltrue='true';
Lfalse='false';

parval=[];
strc=evalc([ ...
     '!fgrep -v "#" ' datafile ...
     '| grep -i ''' str ''' - ' ...
     '| tail -1 ' ...
     '| sed ''s/.*=//'' ' ...
     '| sed ''s/,.*/;/'' ' ...
     '| sed ''s/\.[tT][rR][uU][eE]\./Ltrue/'' ' ...
     '| sed ''s/\.[fF][aA][lL][sS][eE]\./Lfalse/'' ' ...
     ]);
if ~isempty(strc)
 eval([ 'parval=' strc ]);
end
