sgeSubmitFcn.m

function sgeSubmitFcn(scheduler, job, props, runtime_limit)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                         %
% Submit a Matlab job to a SGE scheduler  %
%                                         %
% Copyright 2007 ECDF System Team         %
% University of Edinburgh                 %
%                                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

scriptName = '/exports/work/is_iti_ug/ywan/sgeWrapper.sh';

% Submit the wrapper script to SGE once for each task, supplying a different
% environment each time.

for i = 1:props.NumberOfTasks
    fprintf('Submitting task %i\n', i);

    logFile = sprintf( '/exports/work/is_iti_ug/ywan/matlab-test/windows-desktop/Job%d_Task%d.out', job.ID, job.Tasks(i).ID );

    cmdLine = sprintf( 'qsub -v \
        MDCE_DECODE_FUNCTION=sgeDecodeFunc,\
        MDCE_STORAGE_LOCATION=%s,\
        MDCE_STORAGE_CONSTRUCTOR=%s,\
        MDCE_JOB_LOCATION=%s,\
        MDCE_DEBUG=true,\
        MDCE_MATLAB_EXE=/exports/home/local/Cluster-Apps/matlab-mdce/3.1-r2007a/bin/worker,\
        MDCE_MATLAB_ARGS=%s,\
        MDCE_TASK_LOCATION=%s \
        -cwd -N Job%d.%d  -l s_rt=%s -j yes -o %s %s', ...
        props.StorageLocation, props.StorageConstructor, \
        props.JobLocation, props.MatlabArguments, props.TaskLocations{i}, \
        job.ID, job.Tasks(i).ID, runtime_limit, logFile, scriptName );

    full_cmd = sprintf('ssh eddie.ecdf.ed.ac.uk %s', cmdLine);

     disp(full_cmd);

     [s, w] = system( full_cmd );

    if s ~= 0
        warning( 'distcompexamples:generic:SGE', ...
                 'Submit failed with the following message:\n%s', w);
    else
        % The output of successful submissions shows the SGE job identifier%
        fprintf( 1, 'Job output will be written to: %s\nQSUB output: %s\n', logFile, w );
    end
end

sgeSubmitFcn.m (linux) (last edited 2007-11-29 12:12:27 by Yuan WAN)