Changeset 269


Ignore:
Timestamp:
Nov 10, 2011, 5:15:48 PM (12 years ago)
Author:
gostiaux
Message:

batch_file_list included in launch_jobs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r268 r269  
    15441544        case 'sge'
    15451545            % choice of batch priority:
    1546             ind_answer=2;
    15471546            [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix)
    15481547            if isequal(s,0)
     
    15611560                    'SelectionMode','single',...
    15621561                    'ListString',str,'ListSize',[200 100],'Name','job priority','InitialValue',3);
    1563                 pvalue=num2str((1-ind_answer)*500); %
    1564                
     1562                pvalue=num2str((1-ind_answer)*500); %                 
    15651563                if isequal(v,0) % to handle Cancel button and figure close,
    15661564                    errormsg='job cancelled';
     
    15691567            else
    15701568                msgbox_uvmat('ERROR','sge batch system not available')
     1569                return
     1570            end
     1571        case 'oar'
     1572            [s,w]=unix('oarstat'); %check the waiting list (command unix)
     1573            if ~isequal(s,0)
     1574                msgbox_uvmat('ERROR','oar batch system not available')
    15711575                return
    15721576            end
     
    17421746
    17431747super_cmd=[];
     1748batch_file_list=[];
    17441749   
    17451750for ifile=1:nbfield
     
    17631768        end
    17641769        [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extension)
    1765         flname=fullfile(Rootbat,Filebat);
    1766         if batch
    1767             filename_bat=fullfile(Rootbat,['job_' Filebat]);
    1768         else
    1769             filename_bat=flname;
    1770         end
    1771         filename_bat=[filename_bat '.bat'];
     1770
     1771        filename_bat=[fullfile(Rootbat,Filebat) '.bat'];
    17721772       
    17731773        %CIV1
     
    21242124                fprintf(fid,cmd);
    21252125                fclose(fid);
    2126                 if batch
    2127                     switch batch_mode
    2128                         case 'sge'                           
    2129                             display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]);
    2130                             eval(  ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]);
    2131                         case 'oar'
    2132 %                             eval(  ['!chmod +x ' filename_bat]);
    2133 %                             %eval(  ['!oarsub -n CIVX -l /core=1,walltime=00:10:00  ' filename_bat]);                   
    2134 %                             eval(  ['!oarsub -n CIVX -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:10:00"   ' filename_bat]);
    2135 
    2136                     cmd_str=['. ' filename_bat];
    2137                     super_cmd{length(super_cmd)+1}=cmd_str;
    2138                            
    2139                     end
    2140                 else
    2141                     %% to lauch the jobs locally :
    2142                     if(isunix)
    2143                         cmd_str=['. ' filename_bat];
    2144                     else %case of Windows
    2145                         cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"'];
    2146                     end
    2147                     super_cmd=[super_cmd cmd_str '\n'];
    2148                     disp(cmd_str);
    2149                 end
     2126               
     2127                batch_file_list{length(batch_file_list)+1}=filename_bat;
     2128               
     2129%                 if batch
     2130%                     switch batch_mode
     2131%                         case 'sge'                           
     2132%                             display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]);
     2133%                             eval(  ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]);
     2134%                         case 'oar'
     2135% %                             eval(  ['!chmod +x ' filename_bat]);
     2136% %                             %eval(  ['!oarsub -n CIVX -l /core=1,walltime=00:10:00  ' filename_bat]);                   
     2137% %                             eval(  ['!oarsub -n CIVX -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:10:00"   ' filename_bat]);
     2138%
     2139%                     cmd_str=['sh ' filename_bat];
     2140%                     super_cmd{length(super_cmd)+1}=cmd_str;
     2141%                           
     2142%                     end
     2143%                 else
     2144%                     %% to lauch the jobs locally :
     2145%                     if(isunix)
     2146%                         cmd_str=['. ' filename_bat];
     2147%                     else %case of Windows
     2148%                         cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"'];
     2149%                     end
     2150%                     super_cmd=[super_cmd cmd_str '\n'];
     2151%                     disp(cmd_str);
     2152%                 end
    21502153            case 'Matlab'
    21512154                drawnow
     
    22322235
    22332236if batch
    2234     switch batch_mode
     2237    switch batch_mode                       
     2238        case 'sge'
     2239            for p=1:length(batch_file_list)
     2240                cmd=['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}];
     2241                display(cmd);eval(cmd);
     2242            end
    22352243        case 'oar'
    2236             l=length(super_cmd);
    2237             for p=0:floor(l/6);
    2238                
    2239                 filename_superbat=fullfile(Rootbat,['job_list_' num2str(p) '.bat']);
     2244            for p=0:floor(length(batch_file_list)/6);               
     2245                filename_batch_group=fullfile(Rootbat,['job_list_' num2str(p) '.bat']);
     2246                fid=fopen(filename_batch_group,'w');
     2247                if fid==-1
     2248                    msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat])
     2249                    return
     2250                end
     2251                if p==floor(length(batch_file_list)/6)
     2252                    kmax=mod(length(batch_file_list),6);
     2253                else
     2254                    kmax=6;
     2255                end
     2256                for k=1:kmax
     2257                    fprintf(fid,['sh ' batch_file_list{p*6+k} '\n']);
     2258                end
     2259                fclose(fid);
     2260                system(['chmod +x ' filename_batch_group]);
     2261                eval(  ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00"   ' filename_batch_group]);
     2262            end
     2263        case 'oar_new' % to be develloped with Patrick Begou
     2264                filename_joblist=fullfile(Rootbat,'job_list.txt');
    22402265                fid=fopen(filename_superbat,'w');
    22412266                if fid==-1
     
    22432268                    return
    22442269                end
    2245                 if p==floor(l/6)
    2246                     kmax=mod(l,6);
    2247                 else
    2248                     kmax=6;
    2249                 end
    2250                 for k=1:kmax
    2251                     fprintf(fid,[super_cmd{p*6+k} '\n']);
     2270                for p=1:length(batch_file_list)
     2271                    fprintf(fid,[batch_file_list{p} '\n']);
    22522272                end
    22532273                fclose(fid);
    2254                 if(isunix)
    2255                     system(['chmod +x ' filename_superbat]);
    2256                 end
    2257                
    2258                 eval(  ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00"   ' filename_superbat]);
    2259             end
    2260     end
    2261 end
    2262            
    2263 
    2264 if ~batch && ~isequal(CivMode,'Matlab')
    2265     [Rootbat,Filebat,extbat]=fileparts(filename_bat);
    2266     filename_superbat=fullfile(Rootbat,'job_list.bat');
    2267     fid=fopen(filename_superbat,'w');
    2268     if fid==-1
    2269         msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat])
    2270         return
    2271     end
    2272     fprintf(fid,super_cmd');
    2273     fclose(fid);
    2274     if(isunix)
    2275         system(['chmod +x ' filename_superbat])
    2276     end
    2277     system([filename_superbat ' &'])% execute main commmand
    2278 end
     2274                walltime=datestr(length(super_cmd)*10/24/60,13);
     2275                eval(  ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=' walltime '"   ' filename_superbat]);
     2276    end
     2277else
     2278    if ~isequal(CivMode,'Matlab')
     2279        filename_superbat=fullfile(Rootbat,'job_list.bat');
     2280        fid=fopen(filename_superbat,'w');
     2281        if fid==-1
     2282            msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat])
     2283            return
     2284        end
     2285        for p=1:length(batch_file_list)
     2286            if isunix
     2287                fprintf(fid,['sh ' batch_file_list{p} '\n']);
     2288            else
     2289                fprintf(fid,['@call "' regexprep(filename_bat,'\\','\\\\') '"' '\n']);
     2290            end
     2291        end
     2292        fclose(fid);
     2293        if(isunix)
     2294            system(['chmod +x ' filename_superbat]);
     2295        end
     2296        system([filename_superbat ' &']);% execute main commmand
     2297    end
     2298   
     2299end
     2300
    22792301
    22802302%% save interface state
     
    42254247   % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx
    42264248else %Windows system
    4227                     flname=regexprep(flname,'\\','\\\\');
     4249%                     flname=regexprep(flname,'\\','\\\\');
    42284250%                     cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n'];
    4229     filename=regexprep(filename,'\\','\\\\');
     4251%     filename=regexprep(filename,'\\','\\\\');
    42304252    cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"\n'];% copy the .civ1.cmx parameter file to .cmx
    42314253    cmd_CIV1=['"' sparam.Civ1Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file
Note: See TracChangeset for help on using the changeset viewer.