ProcessParallelParametersFromCieloRc

PURPOSE ^

PROCESSPARALLELPARAMETERSFROMCIELORC - process parallel parameters from cielo

SYNOPSIS ^

function [server_codepath server_executionpath]=ProcessParallelParametersFromCieloRc(server_name,cielo_rc_location)

DESCRIPTION ^

PROCESSPARALLELPARAMETERSFROMCIELORC - process parallel parameters from cielo

   This function reads through the cielo_rc_location for server settings (name, ip, port and 
   tunneling) used to run parallel solution sequences

   Usage:
      [server_codepath server_executionpath]=ProcessParallelParametersFromCieloRc(server_name,cielo_rc_location)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [server_codepath server_executionpath]=ProcessParallelParametersFromCieloRc(server_name,cielo_rc_location)
0002 %PROCESSPARALLELPARAMETERSFROMCIELORC - process parallel parameters from cielo
0003 %
0004 %   This function reads through the cielo_rc_location for server settings (name, ip, port and
0005 %   tunneling) used to run parallel solution sequences
0006 %
0007 %   Usage:
0008 %      [server_codepath server_executionpath]=ProcessParallelParametersFromCieloRc(server_name,cielo_rc_location)
0009 
0010 lines_per_server=5;
0011 %open cielo.rc file
0012 fid=fopen(cielo_rc_location);
0013 if fid==-1,
0014     error('Could not find cielo.rc file in delivery directory');
0015 end
0016 
0017 found=0;
0018 
0019 %Read first line and check it starts with begin.
0020 line=fgetl(fid);
0021 if ~strcmp(line,'begin'),
0022     error('cielo.rc file in delivery directory should always start with the begin statement');
0023 end
0024 
0025 %Read until we find the end statement.
0026 while 1
0027     line=fgetl(fid);
0028     
0029     %Check for 'end' statement
0030     if strcmp(line,'end'),
0031         break;
0032     end 
0033     %Check for end of file
0034     if ~ischar(line),
0035         error('cielo.rc file in delivery directory should end with an end statement');
0036     end
0037     %Ignore empty lines
0038     if length(line)==0,
0039         continue;
0040     end
0041     %Ignore comments
0042     if strcmp(line(1),'#'),
0043         continue
0044     end
0045 
0046     %Handle server name:
0047     if length(line)>11,
0048         if strcmp(line(1:11),'server_name'),
0049             %ok, the next 4 lines deal with one server settings.
0050             %check if this is the server we are looking for.
0051             splittedstring=strsplit(line,'=');
0052             this_server_name=splittedstring{2};
0053             if strcmp(this_server_name,server_name),
0054 
0055                 %Skip next 3 lines
0056                 line=fgetl(fid);
0057                 line=fgetl(fid);
0058                 line=fgetl(fid);
0059 
0060                 %Get next line for server code path
0061                 line=fgetl(fid);
0062                 splittedstring=strsplit(line,'=');
0063                 descriptor=splittedstring{1};
0064                 value=splittedstring{2};
0065                 if ~strcmp(descriptor,'server_codepath'),
0066                     error('server settings in cielo.rc don''t follow the correct syntax');
0067                 end
0068                 server_codepath=value;
0069                 found=1;
0070                 
0071                 
0072                 %Get next line for server execution path
0073                 line=fgetl(fid);
0074                 splittedstring=strsplit(line,'=');
0075                 descriptor=splittedstring{1};
0076                 value=splittedstring{2};
0077                 if ~strcmp(descriptor,'server_executionpath'),
0078                     error('server settings in cielo.rc don''t follow the correct syntax');
0079                 end
0080                 server_executionpath=value;
0081 
0082             else
0083                 %Wrong server name, skip next lines_per_server lines and continue;
0084                 for i=1:lines_per_server,
0085                     line=fgetl(fid);
0086                 end
0087                 continue;
0088             end
0089         end
0090     end
0091 end
0092 
0093 fclose(fid);
0094 
0095 if found==0,
0096     error(['ProcessParallelParametersFromCieloRc error message: could not find setting for cluster ' server_name 'in cielo.rc file']);
0097 end
0098 
0099 end %close of function

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003