% File: clumeq.m"
% Author: Albert Law [bleuant@cim.mcgill.ca] (McGill University, Montreal, Quebec, Canada)
% Description: This is written for CLUMEQ [http://www.clumeq.mcgill.ca/]
% execution. It reads in "batch.m" and then writes a bunch of M-files and
% PBS file that it will automatically add the the queue.
% Note #1: Must only be executed on hn.clumeq.mcgill.ca
% Note #2: The entire point is the run ALL the test cases in parallel at
% one time or else it is faster to execute the test case (singular) on a
% local machine.
% Note #3: Not well documented as this was done as a fast hack.
% Note #4: All the directories are hardcoded. Beware!
% only proceed if all other queues have already been processed
[s, out] = system ('qstat | grep alaw');
while (sum(size(out)) > 0)
disp(fix(clock));
system('sleep 600');
[s, out] = system ('qstat | grep alaw');
end;
fid = fopen('batch.m'); % open up "batch.m" for CLUMEQ parrallel processing
% set the header information for the PBS file
headerPBS = ['#PBS -l ncpus=1 '; '#PBS -V '; 'cd /home2/alaw/et/clumeq '; '/home/software/matlab/bin/matlab < ';];
% read the first 30-lines of "batch.m" for header information
headerM = repmat(' ', 30, 256);
iter = 1;
while ((feof(fid) ~= 1) && (iter <= 30))
temp = fgets(fid);
headerM(iter,1:size(temp,2)) = temp;
iter = iter + 1;
end;
iterFOEF = 1;
while (feof(fid) ~= 1)
temp = fgetl(fid);
if ((max(size(temp))>=2) & (strcmpi (temp(1:2), 'go'))) % this line does contain a "go" command
% write the M-file
temp_fid = fopen (['clumeq', filesep, 'batch_', num2str(iterFOEF), '.m'], 'w');
fprintf(temp_fid, '%s\n', 'cd ..');
iterH = 1;
while (iterH <= size(headerM,1))
fprintf(temp_fid, '%s\n', headerM(iterH,:));
iterH = iterH + 1;
end;
fprintf(temp_fid, '\n%s\n', temp);
fclose(temp_fid);
% write the PBS file
temp_fid = fopen (['clumeq', filesep, 'batch-', num2str(iterFOEF), '.pbs'], 'w');
iterH = 1;
while (iterH < size(headerPBS,1))
fprintf(temp_fid, '%s\n', headerPBS(iterH,:));
iterH = iterH + 1;
end;
fprintf(temp_fid, '%s\n', strcat(headerPBS(iterH,:), [' batch_', num2str(iterFOEF), '.m']));
fclose(temp_fid);
% submit the PBS file to the CLUMEQ queue
system(['qsub clumeq', filesep, 'batch-', num2str(iterFOEF), '.pbs']);
iterFOEF = iterFOEF + 1;
end;
end;
fclose(fid);
Topic revision: r1 - 2006-05-10
- bleuant