function stat=orca90(svp_file,opt_file,out_file)
%
% Call stat=orca90(svp_file,opt_file,out_file);
%
% Function that calls the ORCA90 executable.
%
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
fid2 = fopen('orca_in','w');
if fid2<0, 
	error(['CANNOT OPEN FILE ','orca_in','; CHECK THAT IT IS NOT IN USE.']);
end
if any(svp_file==' '),
    disp('WARNING: spaces in path to svp_file may cause ORCA to not work!!');
end
fprintf(fid2,'%s\n',svp_file);
fprintf(fid2,'%s\n',opt_file);
fprintf(fid2,'%s\n',out_file);
fclose(fid2);
%
if (isunix || ispc)
   if (exist('system','builtin') == 0)
      !orca90
   else
	[syserr]=system('orca90');
      if syserr ~= 0
         disp('An error occurred during the system call to orca90')
%          disp(w);
         disp('Make sure that the orca90 binary executable is in your execution path')
         disp('A ''bin'' directory containing binary executables was supplied with this package')
      end
   end
elseif isppc,
    disp('Mac platform not supported');
end
stat=0;
if exist('orca_status','file'),
    fid=fopen('orca_status','r');
    line1=fgetl(fid);
    if ~isempty(findstr(line1,'successfully')), stat=1; end
    fclose(fid);
end
