Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 917)
+++ /trunk/src/series.m	(revision 918)
@@ -1480,5 +1480,5 @@
 end
 
-%% Get RunTime code from the file PARAM.xml (needed to run compiled functions)
+%% Get  PARAM.xml (not used at this stage)
 errormsg='';%default error message
 xmlfile=fullfile(path_series,'PARAM.xml');
@@ -1761,41 +1761,59 @@
         '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n'])
     RunMode = 'python';
-    t = struct2xml(Param);
-    t = set(t, 1, 'name', 'Series');
-    filexml = fullfile_uvmat(DirXml, '', Param.InputTable{1,3}, '.xml', OutputNomType,...
-         Param.IndexRange.first_i, Param.IndexRange.last_i, first_j, last_j);
-    save(t, filexml);
 end
 
 
 %% direct processing on the current Matlab session
-if strcmp (RunMode,'local')
-    for iprocess=1:NbProcess
-        if ~strcmp(get(handles.RUN,'BusyAction'),'queue')% allow for STOP action
-            disp('program stopped by user')
-            return
-        end
-        if isempty(Param.IndexRange.NbSlice)
-            %Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;
-            Param.IndexRange.first_i=ref_i(1+(iprocess-1)*BlockLength);
-            if Param.IndexRange.first_i>last_i
-                break
-            end
-            Param.IndexRange.last_i=min(ref_i(iprocess*BlockLength),last_i);
-            %Param.IndexRange.last_i=min(first_i+(iprocess)*BlockLength*incr_i-1,last_i);
-        else %multislices (then incr_i is not empty)
-            Param.IndexRange.first_i= first_i+incr_i*(iprocess-1);
-            Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice;
-        end
-        if isfield(Param,'OutputSubDir')
-            t=struct2xml(Param);
-            t=set(t,1,'name','Series');
-            filexml=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,...
-                Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
-            save(t,filexml);
-        end
+% if strcmp (RunMode,'local')
+for iprocess=1:NbProcess
+    if ~strcmp(get(handles.RUN,'BusyAction'),'queue')% allow for STOP action
+        disp('program stopped by user')
+        return
+    end
+    if isempty(Param.IndexRange.NbSlice)
+        Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;
+%         Param.IndexRange.first_i=ref_i(1+(iprocess-1)*BlockLength);
+        if Param.IndexRange.first_i>last_i
+            NbProcess=iprocess-1;% leave the loop, we are at the end of the calculation
+            break
+        end
+        %Param.IndexRange.last_i=min(ref_i(iprocess*BlockLength),last_i);
+        %Param.IndexRange.last_i=min(first_i+(iprocess)*BlockLength*incr_i-1,last_i);
+        Param.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1);
+    else %multislices (then incr_i is not empty)
+%         Param.IndexRange.first_i= first_i+incr_i*(iprocess-1);
+%         Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice;
+        Param.IndexRange.first_i= first_i+iprocess-1;
+        Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice;
+    end
+    for ilist=1:size(Param.InputTable,1)
+        Param.InputTable{ilist,1}=regexprep(Param.InputTable{ilist,1},'\','/');%correct path name for PCWIN system
+    end
+    
+    %         if isempty(Param.IndexRange.NbSlice)% process by blocks of i index
+    %             Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;
+    %             if Param.IndexRange.first_i>last_i
+    %                 NbProcess=iprocess-1;
+    %                 break% leave the loop, we are at the end of the calculation
+    %             end
+    %             Param.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1);
+    %         else% process by slices of i index if NbSlice is defined, computation in a single process if NbSlice =1
+    %             Param.IndexRange.first_i= first_i+iprocess-1;
+    %             Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice;
+    %         end
+    
+    
+    if isfield(Param,'OutputSubDir')
+        t=struct2xml(Param);
+        t=set(t,1,'name','Series');
+        extxml{iprocess}=fullfile_uvmat('','',Param.InputTable{1,3},'.xml',OutputNomType,...
+            Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
+        filexml{iprocess}=fullfile(OutputDir,'0_XML',extxml{iprocess})
+        save(t, filexml{iprocess});% save the xml file containing the processing parameters
+    end
+    if strcmp (RunMode,'local')
         switch ActionExt
             case '.m'
-                h_fun(Param);
+                h_fun(Param);% direct launching
             case '.sh'
                 switch computer
@@ -1808,5 +1826,6 @@
         end
     end
-elseif ~strcmp(RunMode,'python')
+end
+if ~strcmp (RunMode,'local') && ~strcmp(RunMode,'python')
     %% processing on a different session of the same computer (background) or cluster, create executable files
     batch_file_list=cell(NbProcess,1);% initiate the list of executable files
@@ -1835,47 +1854,40 @@
         end
     end
+    %create the executable file
+    file_exe_global=fullfile_uvmat('','',Param.InputTable{1,3},ExeExt,OutputNomType,...
+        first_i,last_i,first_j,last_j);
+    file_exe_global=fullfile(OutputDir,'0_EXE',file_exe_global);
+    filelog_global=fullfile_uvmat('','',Param.InputTable{1,3},'.log',OutputNomType,...
+        first_i,last_i,first_j,last_j);
+    filelog_global=fullfile(OutputDir,'0_LOG',filelog_global);
+    
+    
     for iprocess=1:NbProcess
-        if isempty(Param.IndexRange.NbSlice)% process by blocks of i index
-            Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;
-            if Param.IndexRange.first_i>last_i
-                NbProcess=iprocess-1;
-                break% leave the loop, we are at the end of the calculation
-            end
-            Param.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1);
-        else% process by slices of i index if NbSlice is defined, computation in a single process if NbSlice =1
-            Param.IndexRange.first_i= first_i+iprocess-1;
-            Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice;
-        end
-        for ilist=1:size(Param.InputTable,1)
-            Param.InputTable{ilist,1}=regexprep(Param.InputTable{ilist,1},'\','/');%correct path name for PCWIN system
-        end
-        % create, fill and save the xml parameter file
-        t=struct2xml(Param);
-        t=set(t,1,'name','Series');
-        filexml{iprocess}=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,...
-            Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
-        save(t,filexml{iprocess});% save the parameter file
         
+        %create the executable file
+        
+        batch_file_list{iprocess}=fullfile(OutputDir,'0_EXE',regexprep(extxml{iprocess},'.xml$',ExeExt));
+%         [fid,message]=fopen(batch_file_list{iprocess},'w');% create the executable file
+%         if isequal(fid,-1)
+%             errormsg=['creation of ' batch_file_list{iprocess} ':' message];
+%             return
+%         end
         
         % set the log file name
-        filelog{iprocess}=fullfile_uvmat(DirLog,'',Param.InputTable{1,3},'.log',OutputNomType,...
-            Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
+        filelog{iprocess}=fullfile(OutputDir,'0_LOG',regexprep(extxml{iprocess},'.xml$','.log'));
+        
     end
 end
 
 %% launch the executable files for background or cluster processing
+
 switch RunMode
+    
     case 'background'
-        % create the executable file
-        filebat=fullfile_uvmat(DirExe,'',Param.InputTable{1,3},ExeExt,OutputNomType,...
-            first_i,last_i,first_j,last_j);
-        %batch_file_list{iprocess}=filebat;
-        [fid,message]=fopen(filebat,'w');% create the executable file
+        [fid,message]=fopen(file_exe_global,'w');
         if isequal(fid,-1)
-            errormsg=['creation of .bat file: ' message];
+            errormsg=['creation of ' file_exe_global ':' message];
             return
         end
-        filelog=fullfile_uvmat(DirLog,'',Param.InputTable{1,3},'.log',OutputNomType,...
-           first_i,last_i,first_j,last_j);
         switch ActionExt
             case '.m'% Matlab function
@@ -1885,5 +1897,5 @@
                             '#!/bin/bash \n'...
                             '. /etc/sysprofile \n'...
-                            'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'...
+                            'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog_global ''' <<END_MATLAB \n'...
                             'addpath(''' path_series '''); \n'...
                             'addpath(''' Param.Action.ActionPath '''); \n'];
@@ -1894,5 +1906,5 @@
                         fprintf(fid,cmd);%fill the executable file with the  char string cmd
                         fclose(fid);% close the executable file
-                        system(['chmod +x ' filebat]);% set the file to executable
+                        system(['chmod +x ' file_exe_global]);% set the file to executable
                     case {'PCWIN','PCWIN64'}
                         cmd=['matlab -automation -logfile ' regexprep(filelog{iprocess},'\\','\\\\')...
@@ -1900,5 +1912,5 @@
                             'addpath(''' regexprep(Param.Action.ActionPath,'\\','\\\\') ''');'];
                         for iprocess=1:NbProcess
-                            cmd=[cmd '' Param.Action.ActionName  '( ''' regexprep(filexml{iprocess},'\\','\\\\') ''');']   
+                            cmd=[cmd '' Param.Action.ActionName  '( ''' regexprep(filexml{iprocess},'\\','\\\\') ''');']
                         end
                         cmd=[cmd ';exit"'];
@@ -1906,131 +1918,164 @@
                         fclose(fid);% close the executable file
                 end
-                system([filebat ' &'])% directly execute the command file 
+                system([file_exe_global ' &'])% directly execute the command file
             case '.sh' % compiled Matlab function
-                switch computer
-                    case {'GLNX86','GLNXA64','MACI64'}
-                        cmd=['#!/bin/bash \n '...
-                            '#$ -cwd \n '...
-                            'sleep $(( $RANDOM / 3000 )) \n '...
-                            'hostname && date \n '...
-                            'umask 002 \n']
-                        for iprocess=1:NbProcess
-                            cmd=[cmd fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml{iprocess}];%allow writting access to created files for user group
-                        end
-                        fprintf(fid,cmd);%fill the executable file with the  char string cmd
-                        fclose(fid);% close the executable file
-                        system(['chmod +x ' filebat]);% set the file to executable
-                        system([filebat ' &'])% directly execute the command file 
-                    case {'PCWIN','PCWIN64'}
-                        msgbox_uvmat('ERROR','option for compiled Matlab functions not implemented for Windows system')
-                        return
+                for iprocess=1:NbProcess
+                    switch computer
+                        case {'GLNX86','GLNXA64','MACI64'}
+                            [fid,message]=fopen(batch_file_list{iprocess},'w');% create the executable file
+                            if isequal(fid,-1)
+                                errormsg=['creation of .bat file: ' message];
+                                return
+                            end
+                            cmd=['#!/bin/bash \n '...
+                                '#$ -cwd \n '...
+                                'hostname && date \n '...
+                                'umask 002 \n'...
+                                fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml];%allow writting access to created files for user group
+                            fprintf(fid,cmd);%fill the executable file with the  char string cmd
+                            fclose(fid);% close the executable file
+                            system(['chmod +x ' batch_file_list{iprocess}]);% set the file to executable
+                            system([batch_file_list{iprocess} ' &'])% directly execute the command file
+                        case {'PCWIN','PCWIN64'}
+                            msgbox_uvmat('ERROR','option for compiled Matlab functions not implemented for Windows system')
+                            return
+                    end
                 end
                 msgbox_uvmat('CONFIRMATION',[ActionName ' launched in background: press STATUS to see results'])
-            case 'cluster_oar' % option 'oar-parexec' used
-                %create subdirectory for oar command and global log files
-                DirOAR=fullfile(OutputDir,'0_OAR');
-                if exist(DirOAR,'dir')% delete the content of the dir 0_LOG to allow new input
-                    curdir=pwd;
-                    cd(DirOAR)
-                    delete('*')
-                    cd(curdir)
-                else
-                    [tild,msg1]=mkdir(DirOAR);
-                    if ~strcmp(msg1,'')
-                        errormsg=['cannot create ' DirOAR ': ' msg1];%error message for directory creation
-                        return
-                    end
-                end
-                filename_joblist=fullfile(DirOAR,'job_list.txt');%create name of the global executable file
-                filename_log=fullfile(DirLog,'job_list.stdout');%file for output messages of the master oar process
-                filename_errors=fullfile(DirLog,'job_list.stderr');%file for error messages of the master oar process
-                
-                fid=fopen(filename_joblist,'w');
-                for p=1:length(batch_file_list)
-                    fprintf(fid,[batch_file_list{p} '\n']);% list of exe files
-                end
-                fclose(fid);
-                system(['chmod +x ' filename_joblist]);% set the file to executable
-                
-                % the command job_list.txt contains the list of NbProcess independent individual jobs
-                % in which the total calculation has been split. Those are written as executable files .sh in the folder /O_EXE.
-                %  These individual jobs are grouped by the system as oar jobs on the NbCore processors.
-                %  For each processor, the oar job must stop after the walltime which has been set, which is limited to 24 h.
-                %  However, the oar job is automatically restarted (option 'idempotent') provided the individual jobs are
-                % shorter than the wall time: in the time interval 'checkpoint' (WallTimeOneJob) before the end of the allowed duration,
-                %  the oar job restarts when an individual job ends.
-                JobTime=CPUTime*BlockLength*nbfield_j;% estimated time for one individual job (in minutes)
-                % wall time (in hours ) for each oar job, allowing 10 individual jobs, but limited to 23 h:
-                WallTimeTotal=min(23,4*JobTime/60);
-                %disp(['WallTimeTotal: ' num2str(WallTimeTotal) ' hours'])
-                % estimated time of an individual job (in min), with a margin of error
-                WallTimeOneJob=min(4*JobTime+10,WallTimeTotal*60/2);% estimated max time of an individual job for checkpoint
-                disp(['WallTimeOneJob: ' num2str(WallTimeOneJob) ' minutes'])
-                oar_command=['oarsub -n UVmat_' ActionName ' '...
-                    '-t idempotent --checkpoint ' num2str(WallTimeOneJob*60) ' '...
-                    '-l /core=' num2str(NbCore) ','...
-                    'walltime=' datestr(WallTimeTotal/24,13) ' '...
-                    '-E ' filename_errors ' '...
-                    '-O ' filename_log ' '...
-                    extra_oar ' '...
-                    '"oar-parexec -s -f ' filename_joblist ' '...
-                    '-l ' filename_joblist '.log"'];
-                fprintf(oar_command);% display  system command on the Matlab command window
-                [status,result]=system(oar_command)% execute system command and show the result (ID number of the launched job) on the Matlab command window
-                filename_oarcommand=fullfile(DirOAR,'0_oar_command');% keep track of the command in file '0-OAR/0_oar_command'
-                fid=fopen(filename_oarcommand,'w');
-                fprintf(fid,oar_command); % store the command
-                fprintf(fid,result);% store the result (job ID number)
-                fclose(fid);
-                
-                msgbox_uvmat('CONFIRMATION',[ActionName ' launched as  ' num2str(NbProcess) ' processes in cluster: press STATUS to see results'])
-            case 'cluster_pbs' % for LMFA Kepler machine
-                %create subdirectory for pbs command and log files
-                DirPBS=fullfile(OutputDir,'0_PBS'); %todo : common name OAR/PBS
-                if exist(DirPBS,'dir')% delete the content of the dir 0_LOG to allow new input
-                    curdir=pwd;
-                    cd(DirPBS)
-                    delete('*')
-                    cd(curdir)
-                else
-                    [tild,msg1]=mkdir(DirPBS);
-                    if ~strcmp(msg1,'')
-                        errormsg=['cannot create ' DirPBS ': ' msg1];%error message for directory creation
-                        return
-                    end
-                end
-                max_walltime=3600*20; % 20h max total calculation (cannot exceed 24 h)
-                walltime_onejob=1800; % seconds, max estimated time for asingle file index value
-                filename_joblist=fullfile(DirPBS,'job_list.txt');%create name of the global executable file
-                fid=fopen(filename_joblist,'w');
-                for p=1:length(batch_file_list)
-                    fprintf(fid,[batch_file_list{p} '\n']);% list of exe files
-                end
-                fclose(fid);
-                system(['chmod +x ' filename_joblist]);% set the file to executable
-                pbs_command=['qstat -n CIVX '...
-                    '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '...
-                    '-l /core=' num2str(NbCore) ','...
-                    'walltime=' datestr(min(1.05*walltime_onejob/86400*max(NbProcess*BlockLength*nbfield_j,NbCore)/NbCore,max_walltime/86400),13) ' '...
-                    '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '...
-                    '-O ' regexprep(filename_joblist,'\.txt\>','.log') ' '...
-                    extra_oar ' '...
-                    '"oar-parexec -s -f ' filename_joblist ' '...
-                    '-l ' filename_joblist '.log"'];
-                filename_oarcommand=fullfile(DirPBS,'pbs_command');
-                fid=fopen(filename_oarcommand,'w');
-                fprintf(fid,pbs_command);
-                fclose(fid);
-                fprintf(pbs_command);% display in command line
-                %system(pbs_command);
-                msgbox_uvmat('CONFIRMATION',[ActionName ' command ready to be launched in cluster'])
-            case 'python'
-                command = [
-                    'LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | pyp "p.split('':'') | [s for s in p if ''matlab'' not in s] | '':''.join(p)") ' ...
-                    'python -m fluiddyn.postproc.uvmat ' filexml{iprocess}];
-                % fprintf(['command:\n' command '\n\n'])
-                system(command, '-echo');
-        end
-end
+        end
+        
+    case 'cluster_oar' % option 'oar-parexec' used
+        %create subdirectory for oar commands
+        for iprocess=1:NbProcess            
+            [fid,message]=fopen(batch_file_list{iprocess},'w');% create the executable file
+            if isequal(fid,-1)
+                errormsg=['creation of .bat file: ' message];
+                return
+            end
+            if  strcmp(ActionExt,'.sh')
+            cmd=['#!/bin/bash \n '...
+                '#$ -cwd \n '...
+                'hostname && date \n '...
+                'umask 002 \n'...
+                fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml{iprocess}];%allow writting access to created files for user group
+            else
+                cmd=[...
+                            '#!/bin/bash \n'...
+                            '. /etc/sysprofile \n'...
+                            'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog{iprocess} ''' <<END_MATLAB \n'...
+                            'addpath(''' path_series '''); \n'...
+                            'addpath(''' Param.Action.ActionPath '''); \n'...
+                            '' Param.Action.ActionName  '( ''' filexml{iprocess} '''); \n'...
+                            'exit \n'...
+                            'END_MATLAB \n'];
+            end
+            fprintf(fid,cmd);%fill the executable file with the  char string cmd
+            fclose(fid);% close the executable file
+            system(['chmod +x ' batch_file_list{iprocess}]);% set the file to executable
+        end
+        DirOAR=fullfile(OutputDir,'0_OAR');
+        if exist(DirOAR,'dir')% delete the content of the dir 0_LOG to allow new input
+            curdir=pwd;
+            cd(DirOAR)
+            delete('*')
+            cd(curdir)
+        else
+            [tild,msg1]=mkdir(DirOAR);
+            if ~strcmp(msg1,'')
+                errormsg=['cannot create ' DirOAR ': ' msg1];%error message for directory creation
+                return
+            end
+        end
+        % create file containing the list of jobs
+        filename_joblist=fullfile(DirOAR,'job_list.txt');% name of the file contqining the list of executables
+        fid=fopen(filename_joblist,'w');%open it for writting
+        for iprocess=1:length(batch_file_list)
+            fprintf(fid,[batch_file_list{iprocess} '\n']);% write list of exe files
+        end
+        fclose(fid);
+        system(['chmod +x ' filename_joblist]);% set the file to executable
+        
+        filename_log=fullfile(DirLog,'job_list.stdout');%file for output messages of the master oar process
+        filename_errors=fullfile(DirLog,'job_list.stderr');%file for error messages of the master oar process
+        % the command job_list.txt contains the list of NbProcess independent individual jobs
+        % in which the total calculation has been split. Those are written as executable files .sh in the folder /O_EXE.
+        %  These individual jobs are grouped by the system as oar jobs on the NbCore processors.
+        %  For each processor, the oar job must stop after the walltime which has been set, which is limited to 24 h.
+        %  However, the oar job is automatically restarted (option 'idempotent') provided the individual jobs are
+        % shorter than the wall time: in the time interval 'checkpoint' (WallTimeOneJob) before the end of the allowed duration,
+        %  the oar job restarts when an individual job ends.
+        JobTime=CPUTime*BlockLength*nbfield_j;% estimated time for one individual job (in minutes)
+        % wall time (in hours ) for each oar job, allowing 10 individual jobs, but limited to 23 h:
+        WallTimeTotal=min(23,4*JobTime/60);
+        %disp(['WallTimeTotal: ' num2str(WallTimeTotal) ' hours'])
+        % estimated time of an individual job (in min), with a margin of error
+        WallTimeOneJob=min(4*JobTime+10,WallTimeTotal*60/2);% estimated max time of an individual job for checkpoint
+        disp(['WallTimeOneJob: ' num2str(WallTimeOneJob) ' minutes'])
+        oar_command=['oarsub -n UVmat_' ActionName ' '...
+            '-t idempotent --checkpoint ' num2str(WallTimeOneJob*60) ' '...
+            '-l /core=' num2str(NbCore) ','...
+            'walltime=' datestr(WallTimeTotal/24,13) ' '...
+            '-E ' filename_errors ' '...
+            '-O ' filename_log ' '...
+            extra_oar ' '...
+            '"oar-parexec -s -f ' filename_joblist ' '...
+            '-l ' filename_joblist '.log"'];
+        fprintf(oar_command);% display  system command on the Matlab command window
+        [status,result]=system(oar_command)% execute system command and show the result (ID number of the launched job) on the Matlab command window
+        filename_oarcommand=fullfile(DirOAR,'0_oar_command');% keep track of the command in file '0-OAR/0_oar_command'
+        fid=fopen(filename_oarcommand,'w');
+        fprintf(fid,oar_command); % store the command
+        fprintf(fid,result);% store the result (job ID number)
+        fclose(fid);
+        msgbox_uvmat('CONFIRMATION',[ActionName ' launched as  ' num2str(NbProcess) ' processes in cluster: press STATUS to see results'])
+        
+    case 'cluster_pbs' % for LMFA Kepler machine
+        %create subdirectory for pbs command and log files
+        DirPBS=fullfile(OutputDir,'0_PBS'); %todo : common name OAR/PBS
+        if exist(DirPBS,'dir')% delete the content of the dir 0_LOG to allow new input
+            curdir=pwd;
+            cd(DirPBS)
+            delete('*')
+            cd(curdir)
+        else
+            [tild,msg1]=mkdir(DirPBS);
+            if ~strcmp(msg1,'')
+                errormsg=['cannot create ' DirPBS ': ' msg1];%error message for directory creation
+                return
+            end
+        end
+        max_walltime=3600*20; % 20h max total calculation (cannot exceed 24 h)
+        walltime_onejob=1800; % seconds, max estimated time for asingle file index value
+        filename_joblist=fullfile(DirPBS,'job_list.txt');%create name of the global executable file
+        fid=fopen(filename_joblist,'w');
+        for iprocess=1:length(batch_file_list)
+            fprintf(fid,[batch_file_list{iprocess} '\n']);% list of exe files
+        end
+        fclose(fid);
+        system(['chmod +x ' filename_joblist]);% set the file to executable
+        pbs_command=['qstat -n CIVX '...
+            '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '...
+            '-l /core=' num2str(NbCore) ','...
+            'walltime=' datestr(min(1.05*walltime_onejob/86400*max(NbProcess*BlockLength*nbfield_j,NbCore)/NbCore,max_walltime/86400),13) ' '...
+            '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '...
+            '-O ' regexprep(filename_joblist,'\.txt\>','.log') ' '...
+            extra_oar ' '...
+            '"oar-parexec -s -f ' filename_joblist ' '...
+            '-l ' filename_joblist '.log"'];
+        filename_oarcommand=fullfile(DirPBS,'pbs_command');
+        fid=fopen(filename_oarcommand,'w');
+        fprintf(fid,pbs_command);
+        fclose(fid);
+        fprintf(pbs_command);% display in command line
+        %system(pbs_command);
+        msgbox_uvmat('CONFIRMATION',[ActionName ' command ready to be launched in cluster'])
+    case 'python'
+        command = [
+            'LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | pyp "p.split('':'') | [s for s in p if ''matlab'' not in s] | '':''.join(p)") ' ...
+            'python -m fluiddyn.postproc.uvmat ' filexml{iprocess}];
+        % fprintf(['command:\n' command '\n\n'])
+        system(command, '-echo');
+end
+
 %------------------------------------------------------------------------
 function STOP_Callback(hObject, eventdata, handles)
Index: /trunk/src/series/civ_input.m
===================================================================
--- /trunk/src/series/civ_input.m	(revision 917)
+++ /trunk/src/series/civ_input.m	(revision 918)
@@ -207,20 +207,5 @@
     end
 end
-if ~isfield(Param.IndexRange,'first_j')||isequal(MaxIndex_j,MinIndex_j)% no possibility of j pairs
-    set(handles.ListPairMode,'Value',1)
-    set(handles.ListPairMode,'String',{'series(Di)'})
-elseif  MaxIndex_i==1 && MaxIndex_j>1% simple series in j
-    set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)'})
-    if  MaxIndex_j <= 10
-        set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large
-    end
-else
-    set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice
-    if strcmp(NomTypeNc,'_1-2_1')
-        set(handles.ListPairMode,'Value',3)% advise 'series(Di)'
-    elseif  MaxIndex_j <= 10
-        set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large
-    end
-end
+
 
 %%  transfer the time from the GUI series, or use file index by default
@@ -272,10 +257,4 @@
 %set(handles.CoordUnit,'String',CoordUnit)
 set(handles.SearchRange,'UserData', pxcm_search);
-
-% indicate the min and max indices i and j on the GUI
-set(handles.MinIndex_i,'String',num2str(MinIndex_i))
-set(handles.MaxIndex_i,'String',num2str(MaxIndex_i))
-set(handles.MinIndex_j,'String',num2str(MinIndex_j))
-set(handles.MaxIndex_j,'String',num2str(MaxIndex_j))
 
 
@@ -336,4 +315,28 @@
     end
 end
+
+%% set the menu and default choice of civ pairs
+if ~isfield(Param.IndexRange,'first_j')||isequal(MaxIndex_j,MinIndex_j)% no possibility of j pairs
+    set(handles.ListPairMode,'Value',1)
+    set(handles.ListPairMode,'String',{'series(Di)'})
+elseif  MaxIndex_i==1 && MaxIndex_j>1% simple series in j
+    set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)'})
+    if  MaxIndex_j <= 10
+        set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large
+    end
+else
+    set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice
+    if strcmp(NomTypeNc,'_1-2_1')
+        set(handles.ListPairMode,'Value',3)% advise 'series(Di)'
+    elseif  MaxIndex_j <= 10
+        set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large
+    end
+end
+
+%% indicate the min and max indices i and j on the GUI
+set(handles.MinIndex_i,'String',num2str(MinIndex_i))
+set(handles.MaxIndex_i,'String',num2str(MaxIndex_i))
+set(handles.MinIndex_j,'String',num2str(MinIndex_j))
+set(handles.MaxIndex_j,'String',num2str(MaxIndex_j))
 
 %% set the reference indices from the input file indices
@@ -968,4 +971,5 @@
         index_pair=0;
         %get all the Time intervals in bursts
+        displ_pair_dt='';
         for numod_a=MinIndex_j:MaxIndex_j-1 %nbfield2 always >=2 for 'pair j1-j2' mode
             for numod_b=(numod_a+1):MaxIndex_j
@@ -981,7 +985,9 @@
             
         end
+        if index_pair ~=0
         [tild,indsort]=sort(dt);
         displ_pair=displ_pair(indsort);
         displ_pair_dt=displ_pair_dt(indsort);
+        end
     case 'displacement'
         displ_pair={'Di=Dj=0'};
@@ -1497,7 +1503,7 @@
     end 
 end
-set(hObject,'BackgroundColor',[1 0 1])
 set(handles.ConfigSource,'String','NEW')
 set(handles.OK,'BackgroundColor',[1 0 1])
+
 %------------------------------------------------------------------------
 % --- Executes on button press in CheckMask: common to all panels (civ1, Civ2..)
@@ -1524,8 +1530,4 @@
         testmask=1;
     else % browse for a mask
-%         filemask=get(hObject,'UserData');%look for previous mask name stored as UserData
-%         if exist(filemask,'file')
-%             filebase=filemask;
-%         end
         filemask= uigetfile_uvmat('pick a mask image file:',InputTable{ind_A,1},'image');
         set(hObject,'UserData',filemask);%store for future use
Index: /trunk/src/set_grid.m
===================================================================
--- /trunk/src/set_grid.m	(revision 917)
+++ /trunk/src/set_grid.m	(revision 918)
@@ -24,5 +24,5 @@
 function varargout = set_grid(varargin)
 
-% Last Modified by GUIDE v2.5 01-Mar-2013 22:41:43
+% Last Modified by GUIDE v2.5 26-Jun-2015 08:54:56
 
 % Begin initialization code - DO NOT PLOT
@@ -138,10 +138,10 @@
 UvData=get(huvmat,'UserData');
 if isfield(UvData.Field, 'CoordUnit')&& strcmp(UvData.Field.CoordUnit,'pixel')
-    plot(grid_pix_A(:,1),grid_pix_A(:,2),'.')
-else
-    plot(grid_phys(:,1),grid_phys(:,2),'.')
-end
-
-%% display grid in second image defiend
+    plot(grid_pix_A(:,1),grid_pix_A(:,2),'.','Tag','proj_object')
+else
+    plot(grid_phys(:,1),grid_phys(:,2),'.','Tag','proj_object')
+end
+
+%% display grid in second image defined
 if ~isempty(grid_pix_B)
     hviewfield=view_field(get(handles.imageB,'String'));
@@ -156,4 +156,14 @@
 end
 
+% --- Executes on button press in clear.
+function clear_Callback(hObject, eventdata, handles)
+huvmat=findobj(allchild(0),'tag','uvmat');
+if ~isempty(huvmat)
+    hhuvmat=guidata(huvmat);
+    hpoints=findobj(hhuvmat.PlotAxes,'Tag','proj_object');
+    if ~isempty(hpoints)
+        delete(hpoints)
+    end
+end
 %------------------------------------------------------------------------
 % --- Executes on button press in CoordType.
@@ -184,7 +194,7 @@
 YA=grid_pix_A(:,2);
 unitcolumn=32*ones(size(XA));
-Xchar=num2str(XA);
+Xchar=num2str(XA,2);
 blanc=char(unitcolumn);
-Ychar=num2str(YA);
+Ychar=num2str(YA,2);
 tete=['1 ' num2str(nbpointsA(1))];
 txt=[Xchar blanc Ychar];
@@ -359,2 +369,6 @@
 % Hints: get(hObject,'String') returns contents of ImageA as text
 %        str2double(get(hObject,'String')) returns contents of ImageA as a double
+
+
+
+
