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=/exports/work/is_iti_ug/ywan/matlab-test/windows-desktop,\
        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.StorageConstructor, props.JobLocation, \
        props.MatlabArguments, props.TaskLocations{i}, \
        job.ID, job.Tasks(i).ID, runtime_limit, \
        logFile, scriptName );                 
                   
    
    full_cmd = sprintf('n:\\Putty\\plink eddie %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

Note:

1. Replace the path of scriptName and logFile by yours

2. You need manually fix the string syntax in line cmdline = sprintf.... All the substrings divided by back slash(\) need be concatenated into one line.

sgeSubmitFcn.m (windows) (last edited 2007-11-29 12:08:34 by Yuan WAN)