Changeset 482 for trunk/src


Ignore:
Timestamp:
Jun 26, 2012, 5:27:52 PM (12 years ago)
Author:
gostiaux
Message:

New conventions to launch jobs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r476 r482  
    7373    msgbox_uvmat('WARNING',errormsg);
    7474end
     75
     76
    7577test_batch=0;%default: ,no batch mode available
    7678if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode')
    77     test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod
     79    batch_mode=sparam.BatchParam.BatchMode; %sge is currently the only implemented batch mod
     80    switch batch_mode
     81        case 'sge'
     82            test_command='qstat';
     83        case 'oar'
     84            test_command='oarstat';
     85    end
     86    [s,w]=system(test_command);
     87    if isequal(s,0)
     88        test_batch=1;
     89    end
    7890end
    7991RUNVal=get(handles.RunMode,'Value');
     
    10911103end
    10921104
    1093 %% check batch mode supported
    1094 if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster
    1095     switch batch_mode
    1096         case 'sge'
    1097             test_command='qstat';
    1098         case 'oar'
    1099             test_command='oarstat';
    1100     end   
    1101     [s,w]=system(test_command);
    1102     if ~isequal(s,0)
    1103         errormsg=[batch_mode ' batch system not available'];
    1104         return
    1105     end
    1106 end
    1107 
    1108 %% check if the binaries exist
     1105
     1106%% check if the binaries exist : to move in civ_opening
    11091107% ListProgram=get(handles.Program,'String');
    11101108% Param.CivMode=ListProgram{get(handles.Program,'Value')};
     
    11161114        binary_list={'Civ'};
    11171115    case 'civ_matlab.sh'% compiled version of civ_matlab
    1118         if batch
    1119             binary_list={'CivmBin'};
    1120             % verifier MenuMatlab installe sur le cluster
    1121             % difficile a faire a priori
    1122         end         
     1116        binary_list={'CivmBin'};         
    11231117end
    11241118for bin_name=binary_list %loop on the list of binaries
     
    11271121            [path,name,ext]=fileparts(Param.xml.(bin_name{1}));
    11281122            currentdir=pwd;
     1123            if isempty(path)
     1124                path=fileparts(which('civ.m'));
     1125            end
    11291126            if exist(path,'dir')
    11301127                cd(path);
    11311128                binpath=pwd;%path of the binary
    11321129                Param.xml.(bin_name{1})=fullfile(binpath,[name ext]);
    1133                 cd(currentdir)
     1130                cd(currentdir);
    11341131            else
    11351132                errormsg=['path ' path ' for binaries defined in PARAM.xml does not exist'];
     
    13061303        % create the file used in run or batch
    13071304        switch Param.Program
    1308             case {'civ_matlab','civ_matlab.sh'}
     1305            case {'civ_matlab'}
    13091306                filename_bat=regexprep(Param.OutputFile,'(\w+)([/\\])(\w+$)','$1$20_BAT$2$3.m');
    1310             case {'CivX','CivAll'}
    1311                 filename_bat=regexprep(Param.OutputFile,'(\w+)([/\\])(\w+$)','$1$20_BAT$2$3.bat');
     1307            case {'CivX','CivAll','civ_matlab.sh'}
     1308                switch computer
     1309                    case {'PCWIN','PCWIN64'}
     1310                        filename_bat=regexprep(Param.OutputFile,'(\w+)([/\\])(\w+$)','$1$20_BAT$2$3.bat');
     1311                    case {'GLNX86','GLNXA64','MACI64'}
     1312                        filename_bat=regexprep(Param.OutputFile,'(\w+)([/\\])(\w+$)','$1$20_BAT$2$3.sh');
     1313                end
    13121314        end
    13131315       
     
    13201322        fprintf(fid,cmd);
    13211323        fclose(fid);
    1322         if isunix
    1323             system(['chmod +x ' filename_bat]);
    1324         end
    1325         batch_file_list{length(batch_file_list)+1}=filename_bat;
    13261324       
     1325        % special case for civ_matlab on cluster
     1326        if strcmp(Param.Program,'civ_matlab') && strcmp(Param.RunMode,'cluster')
     1327            filename_bat2=regexprep(Param.OutputFile,'(\w+)([/\\])(\w+$)','$1$20_BAT$2$3.sh');
     1328            [fid,message]=fopen(filename_bat2,'w');
     1329            if isequal(fid,-1)
     1330                errormsg=['creation of .bat file: ' message];
     1331                return
     1332            end
     1333            fprintf(fid,['#!/bin/bash \n' ...
     1334                '/etc/sysprofile \n'...
     1335                'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n'...
     1336                'addpath(''' path_civ ''');\n']);
     1337            for p=1:length(batch_file_list)
     1338                fprintf(fid,['run ' filename_bat '\n']);
     1339            end
     1340            fprintf(fid, 'exit \n END_MATLAB \n');
     1341            fclose(fid);
     1342            filename_bat=filename_bat2;
     1343        end
     1344       
     1345        switch computer
     1346            case {'GLNX86','GLNXA64','MACI64'}
     1347                system(['chmod +x ' filename_bat]);
     1348        end
     1349        batch_file_list{length(batch_file_list)+1}=filename_bat;
    13271350    end
    13281351end
     
    13311354%computation on cluster
    13321355%if batch ==3
    1333  if  strcmp(Param.RunMode,'cluster')
    1334     switch batch_mode   
    1335         case 'sge' %at the moment only psmn ENS Lyon uses it
    1336             for p=1:length(batch_file_list)
    1337                 %cmd=['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}];
    1338                 cmd=['!qsub -q piv1,piv2,piv3 '...
    1339                     '-e ' regexprep(batch_file_list{p},'.bat','.errors') ' -o ' regexprep(batch_file_list{p},'.bat','.log ')...
    1340                     ' -v ' 'LD_LIBRARY_PATH=/home/sjoubaud/matlab_sylvain/civx/lib ' batch_file_list{p}];               
    1341                 display(cmd);eval(cmd);
    1342             end           
    1343         case 'oar_old'
     1356switch Param.RunMode,
     1357    case 'cluster'
     1358        switch batch_mode
     1359            case 'sge' %at the moment only psmn ENS Lyon uses it
     1360                for p=1:length(batch_file_list)
     1361                    %cmd=['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}];
     1362                    cmd=['!qsub -q piv1,piv2,piv3 '...
     1363                        '-e ' regexprep(batch_file_list{p},'.bat','.errors') ' -o ' regexprep(batch_file_list{p},'.bat','.log ')...
     1364                        ' -v ' 'LD_LIBRARY_PATH=/home/sjoubaud/matlab_sylvain/civx/lib ' batch_file_list{p}];
     1365                    display(cmd);eval(cmd);
     1366                end
     1367            case 'oar_old' % to remove
    13441368                for p=1:length(batch_file_list)
    13451369                    oar_command=['!oarsub -n CIVX -q nicejob '...
    1346                    '-E ' regexprep(batch_file_list{p},'.bat','.errors') ' -O ' regexprep(batch_file_list{p},'.bat','.log ')...
    1347                     '-l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00"   ' batch_file_list{p}];
    1348                 display(oar_command);eval(oar_command);
    1349                 end               
    1350         case 'oar'
    1351            
    1352             max_walltime=3600*12; % 12h max
    1353             oar_modes={'oar-parexec','oar-dispatch','mpilauncher'};
    1354             text={'Batch processing on servcalcul3 LEGI';...
    1355                 'Please choose one of the followint modes';...
    1356                 '* oar-parexec : default and best choice';...
    1357                 '* oar-dispatch : jobs in a container of several cores';...
    1358                 '* mpilauncher : one single parallel mpi job using several cores';...
    1359                 '**********************************'...
    1360                 };
    1361             [S,v]=listdlg('PromptString',text,'ListString',oar_modes,...
    1362                 'SelectionMode','single','ListSize',[400 100],'Name','LEGI job mode');
    1363             switch oar_modes{S}
    1364                 case 'oar-parexec' %oar-dispatch.pl
    1365                     answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''});
    1366                     ncores=str2double(answer{1});
    1367                     extra_oar=answer{2};
    1368                     walltime_onejob=600;%seconds
    1369                     filename_joblist=fullfile(RootBat,'job_list.txt');
    1370                     fid=fopen(filename_joblist,'w');
    1371                     for p=1:length(batch_file_list)
    1372                         fprintf(fid,[batch_file_list{p} '\n']);
     1370                        '-E ' regexprep(batch_file_list{p},'.bat','.errors') ' -O ' regexprep(batch_file_list{p},'.bat','.log ')...
     1371                        '-l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00"   ' batch_file_list{p}];
     1372                    display(oar_command);eval(oar_command);
     1373                end
     1374            case 'oar'
     1375                max_walltime=3600*12; % 12h max
     1376                oar_modes={'oar-parexec','oar-dispatch','mpilauncher'};
     1377                text={'Batch processing on servcalcul3 LEGI';...
     1378                    'Please choose one of the followint modes';...
     1379                    '* oar-parexec : default and best choice';...
     1380                    '* oar-dispatch : jobs in a container of several cores';...
     1381                    '* mpilauncher : one single parallel mpi job using several cores';...
     1382                    '**********************************'...
     1383                    };
     1384                [S,v]=listdlg('PromptString',text,'ListString',oar_modes,...
     1385                    'SelectionMode','single','ListSize',[400 100],'Name','LEGI job mode');
     1386                switch oar_modes{S}
     1387                    case 'oar-parexec' %oar-dispatch.pl
     1388                        answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''});
     1389                        ncores=str2double(answer{1});
     1390                        if strcmp(Param.Program,'civ_matlab')
     1391                            ncores=1;
     1392                        end
     1393                        extra_oar=answer{2};
     1394                        walltime_onejob=600;%seconds
     1395                        filename_joblist=fullfile(RootBat,'job_list.txt');
     1396                        fid=fopen(filename_joblist,'w');
     1397                        for p=1:length(batch_file_list)
     1398                            fprintf(fid,[batch_file_list{p} '\n']);
     1399                        end
     1400                        fclose(fid);
     1401                        oar_command=['oarsub -n CIVX '...
     1402                            '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '...
     1403                            '-l /core=' num2str(ncores) ','...
     1404                            'walltime=' datestr(min(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,max_walltime/86400),13) ' '...
     1405                            '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '...
     1406                            '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '...
     1407                            extra_oar ' '...
     1408                            '"oar-parexec -s -f ' filename_joblist ' '...
     1409                            '-l ' filename_joblist '.log"\n'];
     1410                        filename_oarcommand=fullfile(RootBat,'oar_command');
     1411                        fid=fopen(filename_oarcommand,'w');
     1412                        fprintf(fid,oar_command);
     1413                        fclose(fid);
     1414                        fprintf(oar_command);% display in command line
     1415                        system(oar_command);
     1416%                         eval(['! . ' filename
     1417%                             _oarcommand])
     1418                    case 'oar-dispatch' %oar-dispatch.pl
     1419                        ncores=str2double(...
     1420                            inputdlg('Number of cores (max 36)','oarsub parameter',1,{'6'})...
     1421                            );
     1422                        walltime_onejob=600;%seconds
     1423                        filename_joblist=fullfile(RootBat,'job_list.txt');
     1424                        fid=fopen(filename_joblist,'w');
     1425                        for p=1:length(batch_file_list)
     1426                            oar_command=['oarsub -n CIVX '...
     1427                                '-E ' regexprep(batch_file_list{p},'\.bat\>','.stderr') ' -O ' regexprep(batch_file_list{p},'\.bat\>','.stdout ')...
     1428                                '-l "/core=1,walltime=' datestr(walltime_onejob/86400,13) '"   ' batch_file_list{p}];
     1429                            fprintf(fid,[oar_command '\n']);
     1430                        end
     1431                        fclose(fid);
     1432                        oar_command=['oarsub -t container -n civx-container '...
     1433                            '-l /core=' num2str(ncores)...
     1434                            ',walltime=' datestr(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,13) ' '...
     1435                            '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '...
     1436                            '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '...
     1437                            '"oar-dispatch -f ' filename_joblist '"'];
     1438                        filename_oarcommand=fullfile(RootBat,'oar_command');
     1439                        fid=fopen(filename_oarcommand,'w');
     1440                        fprintf(fid,[oar_command '\n']);
     1441                        fclose(fid);
     1442                        display(oar_command);
     1443                        eval(['! . ' filename_oarcommand])
     1444                    case 'mpilauncher'
     1445                        filename_joblist=fullfile(RootBat,'job_list.txt');
     1446                        fid=fopen(filename_joblist,'w');
     1447                       
     1448                        for p=1:length(batch_file_list)
     1449                            fprintf(fid,[batch_file_list{p} '\n']);
     1450                        end
     1451                        fclose(fid)
     1452                        text_oarscript=[...
     1453                            '#!/bin/bash \n'...
     1454                            '#OAR -n Mylauncher \n'...
     1455                            '#OAR -l node=4/core=5,walltime=0:15:00 \n'...
     1456                            '#OAR -E ' fullfile(RootBat,'stderrfile.log') ' \n'...
     1457                            '#OAR -O ' fullfile(RootBat,'stdoutfile.log') ' \n'...
     1458                            '# ========================================================= \n'...
     1459                            '# This simple program launch a multinode parallel OpenMPI mpilauncher \n'...
     1460                            '# application for coriolis PIV post-processing. \n'...
     1461                            '# OAR uses oarshmost wrapper to propagate the user environement. \n'...
     1462                            '# This wrapper assert that the user has the same environment on all the \n'...
     1463                            '# allocated nodes (basic behavior needed by most MPI applications).  \n'...
     1464                            '# \n'...
     1465                            '# REQUIREMENT: \n'...
     1466                            '# the oarshmost wrapper should be installed in $HOME/bin directory. \n'...
     1467                            '# If a different location is used, change the line following the comment "Bidouille" \n'...
     1468                            '# ========================================================= \n'...
     1469                            '#   USER should only modify these 2 lines  \n'...
     1470                            'WORKDIR=' pwd ' \n'...
     1471                            'COMMANDE="mpilauncher  -f ' filename_joblist '" \n'...
     1472                            '# ========================================================= \n'...
     1473                            '# DO NOT MODIFY the FOLOWING LINES. (or be carefull) \n'...
     1474                            'echo "job starting on: "`hostname` \n'...
     1475                            'MPINODES="-host `tr [\\\\\\n] [,] <$OAR_NODEFILE |sed -e "s/,$/ /"`" \n'...
     1476                            'NCPUS=`cat $OAR_NODEFILE |wc -l` \n'...
     1477                            '#========== Bidouille ============== \n'...
     1478                            'export OMPI_MCA_plm_rsh_agent=oar-envsh \n'...%                     'cd $WORKDIR \n'...
     1479                            'CMD="mpirun -np $NCPUS -wdir $WORKDIR $MPINODES $COMMANDE" \n'...
     1480                            'echo "I run: $CMD"  \n'...
     1481                            '$CMD \n'...
     1482                            'echo "job ending" \n'...
     1483                            ];
     1484                        %                 oarsub -S ./oar.sub
     1485                        filename_oarscript=fullfile(RootBat,'oar_command');
     1486                        fid=fopen(filename_oarscript,'w');
     1487                        fprintf(fid,[text_oarscript]);
     1488                        fclose(fid);
     1489                        eval(['!chmod +x  ' filename_oarscript]);
     1490                        eval(['!oarsub -S ' filename_oarscript]);
     1491                end
     1492        end
     1493    case {'background','local'}
     1494        switch Param.Program
     1495            case {'civ_matlab'}
     1496                switch Param.RunMode
     1497                    case 'background'
     1498                        switch computer
     1499                            case {'PCWIN','PCWIN64'}
     1500                                filename_superbat=fullfile(RootBat,'job_list.bat');
     1501                                fid=fopen(filename_superbat,'w');
     1502                                if fid==-1
     1503                                    msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat])
     1504                                    return
     1505                                end
     1506                                    %%% TODO FOR WINDOWS : TRANSLATE
     1507                                    %%% COMMANDS BELOW
     1508%                                 fprintf(fid,['#!/bin/bash \n' ...
     1509%                                     '/etc/sysprofile \n'...
     1510%                                     'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n'...
     1511%                                     'addpath(''' path_civ ''');\n']);
     1512%                                 for p=1:length(batch_file_list)
     1513%                                     fprintf(fid,['run ' batch_file_list{p} '\n']);
     1514%                                 end
     1515%                                 fprintf(fid, 'exit \n END_MATLAB \n');
     1516                                fclose(fid);
     1517%                                 system(['chmod +x ' filename_superbat]);
     1518%                                 system([filename_superbat ' &']);
     1519                            case {'GLNX86','GLNXA64','MACI64'}
     1520                                filename_superbat=fullfile(RootBat,'job_list.sh');
     1521                                fid=fopen(filename_superbat,'w');
     1522                                if fid==-1
     1523                                    msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat])
     1524                                    return
     1525                                end
     1526                                fprintf(fid,['#!/bin/bash \n' ...
     1527                                    '/etc/sysprofile \n'...
     1528                                    'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n'...
     1529                                    'addpath(''' path_civ ''');\n']);
     1530                                for p=1:length(batch_file_list)
     1531                                    fprintf(fid,['run ' batch_file_list{p} '\n']);
     1532                                end
     1533                                fprintf(fid, 'exit \n END_MATLAB \n');
     1534                                fclose(fid);
     1535                                system(['chmod +x ' filename_superbat]);
     1536                                system([filename_superbat ' &']);
     1537                        end
     1538                    case 'local'
     1539                        for p=1:length(batch_file_list)
     1540                            fid=fopen(batch_file_list{p});
     1541                            eval(fscanf(fid,'%s'));
     1542                            fclose(fid);
     1543                        end
     1544                end
     1545            case {'CivX','CivAll','civ_matlab.sh'}
     1546                    switch computer
     1547                        case {'PCWIN','PCWIN64'}
     1548                            filename_superbat=fullfile(RootBat,'job_list.bat');
     1549                            fid=fopen(filename_superbat,'w');
     1550                            if fid==-1
     1551                                msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat])
     1552                                return
     1553                            end
     1554                            for p=1:length(batch_file_list)
     1555                                fprintf(fid,['@call "' regexprep(batch_file_list{p},'\\','\\\\') '"' '\n']);
     1556                            end
     1557                            fclose(fid);
     1558                            system(['chmod +x ' filename_superbat]);
     1559                        case {'GLNX86','GLNXA64','MACI64'}
     1560                            filename_superbat=fullfile(RootBat,'job_list.bat');
     1561                            fid=fopen(filename_superbat,'w');
     1562                            if fid==-1
     1563                                msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat])
     1564                                return
     1565                            end
     1566                            for p=1:length(batch_file_list)
     1567                                fprintf(fid,['sh ' batch_file_list{p} '\n']);
     1568                            end
     1569                            fclose(fid);
     1570                            system(['chmod +x ' filename_superbat]);
    13731571                    end
    1374                     fclose(fid)
    1375                     oar_command=['oarsub -n CIVX '...
    1376                         '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '...
    1377                         '-l /core=' num2str(ncores) ','...
    1378                             'walltime=' datestr(min(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,max_walltime/86400),13) ' '...
    1379                         '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '...
    1380                         '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '...
    1381                         extra_oar ' '...
    1382                         '"oar-parexec -s -f ' filename_joblist ' '...
    1383                             '-l ' filename_joblist '.log"'];
    1384                     filename_oarcommand=fullfile(RootBat,'oar_command');
    1385                     fid=fopen(filename_oarcommand,'w');
    1386                     fprintf(fid,[oar_command '\n']);
    1387                     fclose(fid);
    1388                     display(oar_command);
    1389                     eval(['! . ' filename_oarcommand])
    1390                 case 'oar-dispatch' %oar-dispatch.pl
    1391                     ncores=str2double(...
    1392                         inputdlg('Number of cores (max 36)','oarsub parameter',1,{'6'})...
    1393                         );
    1394                     walltime_onejob=600;%seconds
    1395                     filename_joblist=fullfile(RootBat,'job_list.txt');
    1396                     fid=fopen(filename_joblist,'w');
    1397                     for p=1:length(batch_file_list)
    1398                         oar_command=['oarsub -n CIVX '...
    1399                             '-E ' regexprep(batch_file_list{p},'\.bat\>','.stderr') ' -O ' regexprep(batch_file_list{p},'\.bat\>','.stdout ')...
    1400                             '-l "/core=1,walltime=' datestr(walltime_onejob/86400,13) '"   ' batch_file_list{p}];
    1401                         fprintf(fid,[oar_command '\n']);
    1402                     end
    1403                     fclose(fid);
    1404                     oar_command=['oarsub -t container -n civx-container '...
    1405                         '-l /core=' num2str(ncores)...
    1406                         ',walltime=' datestr(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,13) ' '...
    1407                         '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '...
    1408                         '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '...
    1409                         '"oar-dispatch -f ' filename_joblist '"'];
    1410                     filename_oarcommand=fullfile(RootBat,'oar_command');
    1411                     fid=fopen(filename_oarcommand,'w');
    1412                     fprintf(fid,[oar_command '\n']);
    1413                     fclose(fid);
    1414                     display(oar_command);
    1415                     eval(['! . ' filename_oarcommand])
    1416                 case 'mpilauncher'
    1417                     filename_joblist=fullfile(RootBat,'job_list.txt');
    1418                     fid=fopen(filename_joblist,'w');
    1419                    
    1420                     for p=1:length(batch_file_list)
    1421                         fprintf(fid,[batch_file_list{p} '\n']);
    1422                     end
    1423                     fclose(fid)
    1424                     text_oarscript=[...
    1425                         '#!/bin/bash \n'...
    1426                         '#OAR -n Mylauncher \n'...
    1427                         '#OAR -l node=4/core=5,walltime=0:15:00 \n'...
    1428                         '#OAR -E ' fullfile(RootBat,'stderrfile.log') ' \n'...
    1429                         '#OAR -O ' fullfile(RootBat,'stdoutfile.log') ' \n'...
    1430                         '# ========================================================= \n'...
    1431                         '# This simple program launch a multinode parallel OpenMPI mpilauncher \n'...
    1432                         '# application for coriolis PIV post-processing. \n'...
    1433                         '# OAR uses oarshmost wrapper to propagate the user environement. \n'...
    1434                         '# This wrapper assert that the user has the same environment on all the \n'...
    1435                         '# allocated nodes (basic behavior needed by most MPI applications).  \n'...
    1436                         '# \n'...
    1437                         '# REQUIREMENT: \n'...
    1438                         '# the oarshmost wrapper should be installed in $HOME/bin directory. \n'...
    1439                         '# If a different location is used, change the line following the comment "Bidouille" \n'...
    1440                         '# ========================================================= \n'...
    1441                         '#   USER should only modify these 2 lines  \n'...
    1442                         'WORKDIR=' pwd ' \n'...
    1443                         'COMMANDE="mpilauncher  -f ' filename_joblist '" \n'...
    1444                         '# ========================================================= \n'...
    1445                         '# DO NOT MODIFY the FOLOWING LINES. (or be carefull) \n'...
    1446                         'echo "job starting on: "`hostname` \n'...
    1447                         'MPINODES="-host `tr [\\\\\\n] [,] <$OAR_NODEFILE |sed -e "s/,$/ /"`" \n'...
    1448                         'NCPUS=`cat $OAR_NODEFILE |wc -l` \n'...
    1449                         '#========== Bidouille ============== \n'...
    1450                         'export OMPI_MCA_plm_rsh_agent=oar-envsh \n'...%                     'cd $WORKDIR \n'...
    1451                         'CMD="mpirun -np $NCPUS -wdir $WORKDIR $MPINODES $COMMANDE" \n'...
    1452                         'echo "I run: $CMD"  \n'...
    1453                         '$CMD \n'...
    1454                         'echo "job ending" \n'...
    1455                         ];
    1456                     %                 oarsub -S ./oar.sub
    1457                     filename_oarscript=fullfile(RootBat,'oar_command');
    1458                     fid=fopen(filename_oarscript,'w');
    1459                     fprintf(fid,[text_oarscript]);
    1460                     fclose(fid);
    1461                     eval(['!chmod +x  ' filename_oarscript]);
    1462                     eval(['!oarsub -S ' filename_oarscript]);
    1463             end
    1464     end
    1465  else %computation on local computer
    1466     switch Param.Program
    1467         case {'civ_matlab','civ_matlab.sh'}
    1468 %             
    1469 %             background=1;
    1470             if strcmp(Param.RunMode,'background')
    1471                 filename_superbat=fullfile(RootBat,'job_list.m');
    1472                 fid=fopen(filename_superbat,'w');
    1473                 if fid==-1
    1474                     msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat])
    1475                     return
     1572                switch Param.RunMode
     1573                    case 'background'
     1574                        system([filename_superbat ' &']);% execute main commmand see what it does in dos ?
     1575                    case 'local'
     1576                        system(filename_superbat);
    14761577                end
    1477                
    1478                 fprintf(fid,['#!/bin/bash \n' ...
    1479                  '/etc/sysprofile \n'...
    1480                 'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n']);
    1481  
    1482                
    1483                 fprintf(fid,['addpath(''' path_civ ''');\n']);
    1484                 for p=1:length(batch_file_list)
    1485                     %                 if isunix
    1486                     %                     fprintf(fid,['sh ' batch_file_list{p} '\n']);
    1487                     %                 else
    1488                     %                     fprintf(fid,['@call "' regexprep(batch_file_list{p},'\\','\\\\') '"' '\n']);
    1489                     %                 end
    1490                     fprintf(fid,['run ' batch_file_list{p} '\n']);
    1491                    
    1492                 end
    1493                 fprintf(fid, 'exit \n END_MATLAB \n');
    1494 
    1495                 fclose(fid);
    1496                  eval(['run ' filename_superbat]);               
    1497                  
    1498             else
    1499                 for p=1:length(batch_file_list)
    1500 %                     civ_matlab([batch_file_list{p} '.xml'], [batch_file_list{p} '.nc'])
    1501                     fid=fopen(batch_file_list{p});
    1502                     eval(fscanf(fid,'%s'));
    1503                     fclose(fid);
    1504                 end
    1505             end
    1506            
    1507            
    1508         case {'CivX','CivAll'}
    1509             filename_superbat=fullfile(RootBat,'job_list.bat');
    1510             fid=fopen(filename_superbat,'w');
    1511             if fid==-1
    1512                 msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat])
    1513                 return
    1514             end
    1515             for p=1:length(batch_file_list)
    1516                 if isunix
    1517                     fprintf(fid,['sh ' batch_file_list{p} '\n']);
    1518                 else
    1519                     fprintf(fid,['@call "' regexprep(batch_file_list{p},'\\','\\\\') '"' '\n']);
    1520                 end
    1521             end
    1522             fclose(fid);
    1523             if(isunix)
    1524                 system(['chmod +x ' filename_superbat]);
    1525             end
    1526             background=0;
    1527             if background
    1528                 system([filename_superbat ' &']);% execute main commmand
    1529             else
    1530                 system(filename_superbat);
    1531             end
    1532     end
     1578        end
    15331579end
    15341580
     
    18421888    vers=0;
    18431889    subdir_civ1_new=subdir_civ1;
     1890    answer='No';
    18441891    while detect==1 %create a new subdir if the netcdf files already exist
    18451892        for ifile=1:nbfield
     
    18481895                detect=exist(filename,'file')==2;
    18491896                if detect% if a netcdf file already exists
    1850                     answer=msgbox_uvmat('INPUT_Y-N',['overwrite existing civ files in ' subdir_civ1_new]);
     1897                    if strcmp(answer,'No')
     1898                        answer=msgbox_uvmat('INPUT_Y-N',['overwrite existing civ files in ' subdir_civ1_new]);
     1899                    end
    18511900                    if strcmp(answer,'Yes')
    18521901                        detect=0;
     
    43134362end
    43144363
    4315 if isequal(Param.Program,'CivAll')
    4316     save(CivAllxml,[Param.OutputFile '.xml']);
    4317     cmd=[cmd sparam.CivBin ' -f ' Param.OutputFile '.xml '  CivAllCmd ' >' Param.OutputFile '.log' '\n'];
    4318 end
    4319 
    4320 if isequal(Param.Program,'civ_matlab')
    4321     if strcmp(Param.RunMode,'cluster')||strcmp(Param.RunMode,'background')
     4364switch Param.Program
     4365    case 'CivAll'
     4366        save(CivAllxml,[Param.OutputFile '.xml']);
     4367        cmd=[cmd sparam.CivBin ' -f ' Param.OutputFile '.xml '  CivAllCmd ' >' Param.OutputFile '.log' '\n'];
     4368    case 'civ_matlab'
     4369        cmd=['civ_matlab(''' regexprep(filename,'(\w+)([/\\])(\w+$)','$1$20_XML$2$3.xml') ''','''...
     4370            filename '.nc'');'];
     4371    case 'civ_matlab.sh'
    43224372        cmd=['#!/bin/bash \n '...
    43234373            '#$ -cwd \n '...
    43244374            'hostname && date \n '...
    43254375            'umask 002 \n'...
    4326             Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' Param.OutputFile '.nc'];%allow writting access to created files for user group
    4327        
    4328         fprintf(fid,cmd);
    4329         fclose(fid);
    4330         if isunix
    4331             system(['chmod +x ' filename_bat]);
    4332         end
    4333         batch_file_list{length(batch_file_list)+1}=filename_bat;
    4334     else
    4335         cmd=['civ_matlab(''' regexprep(filename,'(\w+)([/\\])(\w+$)','$1$20_XML$2$3.xml') ''','''...
    4336             filename '.nc'');']
    4337 %         [tild,errormsg]=civ_matlab(Param,filecell.nc.civ1{ifile,j});
    4338     end
    4339 end
    4340    
    4341 
    4342 if isequal(Param.Program,'civ_matlab.sh')
    4343         cmd=['#!/bin/bash \n '...
    4344             '#$ -cwd \n '...
    4345             'hostname && date \n '...
    4346             'umask 002 \n'...
    4347             Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' Param.OutputFile '.nc'];%allow writting access to created files for user group
    4348 end
    4349 
    4350 
    4351 if isequal(Param.Program,'MatlabNonCompile')
    4352 %         cmd=[regexprep(which(civ_matlab),'.m$','')...
    4353 %             '(' regexprep(filename,'(\w+)/(\w+$)','$1/0_XML$2.xml,')...
    4354 %             filename '.nc);'];
    4355 %         [tild,errormsg]=civ_matlab(Param,filecell.nc.civ1{ifile,j});
    4356 end
    4357 
    4358 
    4359 
    4360    
     4376            Param.xml.CivmBin ' ' Param.xml.RunTime ' ' regexprep(filename,'(\w+)([/\\])(\w+$)','$1$20_XML$2$3.xml') ' ' Param.OutputFile '.nc'];%allow writting access to created files for user group
     4377end   
    43614378   
    43624379
Note: See TracChangeset for help on using the changeset viewer.