

function retval = LoadEnvironment (directory)
  
if(directory(end) ~= '/')
directory = [directory '/'];
end
  
SingleValueNames = {'AirDensity',...
                    'AirKinematicViscosity',...
                    'CurrentProfile',...
                    'WaterDepth',...
                    'WaterDensity',...
                    'WaterKinematicViscosity',...
                    'WaveType',...
                    'WindProfile'...
                    };  
  
  
disp(['Opening ' directory 'Initial/env.ini']);
fid = fopen ([directory 'Initial/env.ini']);

do
  str = fgetl (fid);
  if((length(str) > 0) && (str(1) == '$'))  %Something valid to parse..
     for i = 1:length(SingleValueNames)
       test_string = SingleValueNames{i};
       if(~isempty(strfind(test_string,str)) || ~isempty(strfind(str,test_string)))  %Double test required because strfind returns empty if test pattern is longer than string.  Annoying
         cmd = ['retval.' test_string ' = sscanf(str,''%*s %f'',''C'');'];
         eval(cmd);
       end
     end
  end
until(str == -1)


fclose(fid);


end
