Index: trunk/src/series.m
===================================================================
--- trunk/src/series.m	(revision 928)
+++ trunk/src/series.m	(revision 932)
@@ -1644,8 +1644,4 @@
             return
         end
-        [success,msg] = fileattrib(OutputDir,'+w','g','s');% allow writing access for the group of users, recursively in the folder  
-        if success==0
-            msgbox_uvmat('WARNING',{['unable to set group write access to ' OutputDir ':']; msg1});%error message for directory creation
-        end
     end
     
@@ -1659,8 +1655,4 @@
         errormsg=['cannot create ' DirXml ': ' msg1];%error message for directory creation
         return
-    end
-    [success,msg] = fileattrib(DirXml,'+w','g','s');% allow writing access for the group of users, recursively in the folder
-    if success==0
-        msgbox_uvmat('WARNING',{['unable to set group write access to ' DirXml ':']; msg});%error message for directory creation
     end
 end
@@ -1684,5 +1676,5 @@
     incr_j=Param.IndexRange.incr_j;
 end
-if last_i < first_i || last_j < first_j 
+if last_i < first_i || last_j < first_j
     errormsg= 'series/Run_Callback:last field index must be larger or equal to the first one';
     return
@@ -1707,5 +1699,5 @@
         ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
     end
-% increment i is defined: processing is done on first_i:incr_i:last_i;
+    % increment i is defined: processing is done on first_i:incr_i:last_i;
 else
     ref_i=first_i:incr_i:last_i;
@@ -1723,12 +1715,12 @@
 end
 nbfield_j=numel(ref_j); % number of j indices
-BlockLength=numel(ref_i);% by default, job involves the full set of i field indices 
+BlockLength=numel(ref_i);% by default, job involves the full set of i field indices
 NbProcess=1;
 switch RunMode
     case {'cluster_oar','cluster_pbs'}
         if isempty(Param.IndexRange.NbSlice)% if NbSlice is not defined
-             BlockLength= ceil(20/(CPUTime*nbfield_j));% short iterations are grouped such that the minimum time of a process is 20 min.
-             BlockLength=max(BlockLength,ceil(numel(ref_i)/500));% possibly increase the BlockLength to have less than 500 jobs
-             NbProcess=ceil(numel(ref_i)/BlockLength) ; % nbre of processes sent to oar
+            BlockLength= ceil(20/(CPUTime*nbfield_j));% short iterations are grouped such that the minimum time of a process is 20 min.
+            BlockLength=max(BlockLength,ceil(numel(ref_i)/500));% possibly increase the BlockLength to have less than 500 jobs
+            NbProcess=ceil(numel(ref_i)/BlockLength) ; % nbre of processes sent to oar
         else
             NbProcess=Param.IndexRange.NbSlice;% the parameter NbSlice sets the nbre of run processes
@@ -1736,7 +1728,7 @@
         end
     otherwise
-         if ~isempty(Param.IndexRange.NbSlice)
-             NbProcess=Param.IndexRange.NbSlice;% the parameter NbSlice sets the nbre of run processes
-         end
+        if ~isempty(Param.IndexRange.NbSlice)
+            NbProcess=Param.IndexRange.NbSlice;% the parameter NbSlice sets the nbre of run processes
+        end
 end
 
@@ -1749,5 +1741,5 @@
         case 'NbInput_i'
             StatusData.NbOutputFile=numel(ref_i);
-        case 'NbSlice'    
+        case 'NbSlice'
             StatusData.NbOutputFile=str2num(get(handles.num_NbSlice,'String'));
     end
@@ -1827,4 +1819,8 @@
             end
         end
+        %         [success,msg] = fileattrib(filexml{iprocess},'+w','g');% allow writing access for the group of users, recursively in the folder
+        %     if success==0
+        %         msgbox_uvmat('WARNING',{['unable to set group write access to ' filexml{iprocess} ':']; msg});%error message for directory creation
+        %     end
     end
     if strcmp (RunMode,'local')
@@ -1832,4 +1828,5 @@
             case '.m'
                 h_fun(Param);% direct launching
+                
             case '.sh'
                 switch computer
@@ -1843,5 +1840,8 @@
     end
 end
-
+% [success,msg] = fileattrib(DirXml,'+w','g','s');% allow writing access for the group of users, recursively in the folder
+%     if success==0
+%         msgbox_uvmat('WARNING',{['unable to set group write access to ' DirXml ':']; msg});%error message for directory creation
+%     end
 if ~strcmp (RunMode,'local') && ~strcmp(RunMode,'python')
     %% processing on a different session of the same computer (background) or cluster, create executable files
@@ -1871,4 +1871,5 @@
         end
     end
+    
     %create the executable file
     file_exe_global=fullfile_uvmat('','',Param.InputTable{1,3},ExeExt,OutputNomType,...
@@ -1879,5 +1880,13 @@
     filelog_global=fullfile(OutputDir,'0_LOG',filelog_global);
     
-    
+    %     [success,msg] = fileattrib(DirLog,'+w','g','s');% allow writing access for the group of users, recursively in the folder
+    %     if success==0
+    %         msgbox_uvmat('WARNING',{['unable to set group write access to ' DirLog ':']; msg});%error message for directory creation
+    %     end
+    %     [success,msg] = fileattrib(fullfile(OutputDir,'0_EXE'),'+w','g','s');% allow writing access for the group of users, recursively in the folder
+    %     if success==0
+    %         msgbox_uvmat('WARNING',{['unable to set group write access to ' fullfile(OutputDir,'0_EXE') ':']; msg});%error message for directory creation
+    %     end
+    %
     for iprocess=1:NbProcess
         
@@ -1885,9 +1894,9 @@
         
         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
+        %         [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
@@ -1964,5 +1973,5 @@
     case 'cluster_oar' % option 'oar-parexec' used
         %create subdirectory for oar commands
-        for iprocess=1:NbProcess            
+        for iprocess=1:NbProcess
             [fid,message]=fopen(batch_file_list{iprocess},'w');% create the executable file
             if isequal(fid,-1)
@@ -1970,20 +1979,24 @@
                 return
             end
+            %             [success,msg] = fileattrib(batch_file_list{iprocess},'+w','g');% allow writing access for the group of users, recursively in the folder
+            %     if success==0
+            %         msgbox_uvmat('WARNING',{['unable to set group write access to ' batch_file_list{iprocess} ':']; msg});%error message for directory creation
+            %     end
             if  strcmp(ActionExt,'.sh')
-            cmd=['#!/bin/bash \n '...
-                '#$ -cwd \n '...
-                'hostname && date \n '...
-                'umask 002 \n'...
-                ActionFullName ' ' RunTime ' ' filexml{iprocess}];%allow writting access to created files for user group
+                cmd=['#!/bin/bash \n '...
+                    '#$ -cwd \n '...
+                    'hostname && date \n '...
+                    'umask 002 \n'...
+                    ActionFullName ' ' 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'];
+                    '#!/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
@@ -2005,6 +2018,7 @@
         end
         % create file containing the list of jobs
-        filename_joblist=fullfile(DirOAR,'job_list.txt');% name of the file contqining the list of executables
+        filename_joblist=fullfile(DirOAR,'job_list.txt');% name of the file containing the list of executables
         fid=fopen(filename_joblist,'w');%open it for writting
+        %         [success,msg] = fileattrib(filename_joblist,'+w','g');% allow writing access for the group of users,
         for iprocess=1:length(batch_file_list)
             fprintf(fid,[batch_file_list{iprocess} '\n']);% write list of exe files
@@ -2036,8 +2050,8 @@
             '-O ' filename_log ' '...
             extra_oar ' '...
-           '"oar-parexec -s -f ' filename_joblist ' '...
+            '"oar-parexec -s -f ' filename_joblist ' '...
             '-l ' filename_joblist '.log"'];
         
-
+        
         
         fprintf(oar_command);% display  system command on the Matlab command window
@@ -2049,4 +2063,8 @@
         fclose(fid);
         msgbox_uvmat('CONFIRMATION',[ActionFullName ' launched as  ' num2str(NbProcess) ' processes in cluster: press STATUS to see results'])
+        %         [success,msg] = fileattrib(DirOAR,'+w','g','s');% allow writing access for the group of users, recursively in the folder
+        %     if success==0
+        %         msgbox_uvmat('WARNING',{['unable to set group write access to ' DirOAR ':']; msg});%error message for directory creation
+        %     end
         
     case 'cluster_pbs' % for LMFA Kepler machine
@@ -2097,5 +2115,10 @@
         system(command, '-echo');
 end
-
+if exist(OutputDir,'dir')
+    [success,msg] = fileattrib(OutputDir,'+w','g','s');% allow writing access for the group of users, recursively in the folder
+    if success==0
+        msgbox_uvmat('WARNING',{['unable to set group write access to ' OutputDir ':']; msg1});%error message for directory creation
+    end
+end
 %------------------------------------------------------------------------
 function STOP_Callback(hObject, eventdata, handles)
