%  MODIFY BASE CASE DATA 

%  FILENAME: MODBC.M 
%  DATE: November 1994
%  VERSION: 02
%  COPYRIGHT 1993, 1994 M.Gretzinger & T.Marlin
%            McMaster University   

% This m-file is called by CSTR.M. It sets up a menu to allow the user to 
%       modify the base case data for the CSTR.
        
        
while baseloaded ~= 1
    case = input('Enter the name of the base case data file (omit extension):  ','s');
      
    if exist(case) == 2
        eval(case)
        baseloaded = 1;
    else
        disp('')
        disp('Not a valid base case data filename')
    end
end     % while baseloaded...    
      
while 1
  clc
  disp('*************************************************************')
  disp('*                MODIFY BASE CASE DATA                      *')
  disp('*                                                           *')
  disp('*************************************************************')
  disp('')
  disp('SELECT THE APPROPRIATE MENU ITEM')
  disp('')
  disp('MODIFY...')
  disp('                                  PRESENT VALUES')
  fprintf('1) Inlet Temperature, To          %4.2f K\n',tininit)
  fprintf('2) Coolant Inlet Temp, Tcin       %4.2f K\n',tcininit)
  fprintf('3) Coolant flow rate, Fc          %4.2f M^3/min\n',fc)
  fprintf('4) a, coefficient in UA=a*Fc^b    %4.4f (cal/(min*K))/(m^3/min) 10^6\n',a)
  disp('5) Return to main menu')
  disp('')

  m2 = input('Please enter the desired selection:   ');
  
  if isempty(m2), break, end
        
  m2 = round(m2);
  if (m2<1) | (m2>4)
      disp('')
      disp('Not a valid selection')
      disp('')
      disp('Press ENTER to continue')
      pause;
  end    

  if m2 == 1
      tthold = input('Enter new value for inlet temp, To (K):  ')
      if isempty(tthold) 
           tininit = tininit; 
      else     
           tininit = tthold;
      end

  elseif m2 == 2
      tchold = input('Enter new value for coolant inlet temp, Tcin (K):  ')
      if isempty(tchold) 
             tcininit = tcininit; 
             
      else       
             tcininit = tchold ;
      end

  elseif m2 == 3
      fchold  = input('Enter the coolant flow rate, Fc (M^3/min):  ')
      if isempty(fchold)
             fc=fc;
      else        
             fc= fchold;
      end

  elseif m2 == 4
      ahold = input('Enter new value for a, coefficient in UA=a*Fc^b:  ')
      if isempty(ahold)
             a = a; 
      else
             a=ahold;
      end
  elseif m2 == 5
      break
  end    % if m2

end    % while 1 (line )
