Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 824)
+++ /trunk/src/series.m	(revision 825)
@@ -528,4 +528,5 @@
 set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
 xx=double(get(handles.series,'CurrentCharacter')); %get the keyboard character
+if ~isempty(xx)
 switch xx
     case 31 %downward arrow
@@ -544,5 +545,5 @@
         end
 end
-
+end
 
 %------------------------------------------------------------------------
@@ -1451,4 +1452,5 @@
 
 %% create the output data directory if needed
+OutpuDir='';
 if isfield(Param,'OutputSubDir')
     SubDirOut=[get(handles.OutputSubDir,'String') Param.OutputDirExt];
@@ -1491,19 +1493,22 @@
         end
     end
-    OutputNomType=nomtype2pair(Param.InputTable{1,4});% nomenclature for output files
-    DirXml=fullfile(OutputDir,'0_XML');
-    if ~exist(DirXml,'dir')
-        [tild,msg1]=mkdir(DirXml);
-        if ~strcmp(msg1,'')
-            msgbox_uvmat('ERROR',['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
-end
-        
+    
+elseif isfield(Param,'ActionInput')&&isfield(Param.ActionInput,'LogPath')% custom definition of the output dir
+    OutputDir=Param.ActionInput.LogPath;   
+end
+DirXml=fullfile(OutputDir,'0_XML');
+if ~exist(DirXml,'dir')
+    [tild,msg1]=mkdir(DirXml);
+    if ~strcmp(msg1,'')
+        msgbox_uvmat('ERROR',['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
+OutputNomType=nomtype2pair(Param.InputTable{1,4});% nomenclature for output files
+
 %% get the set of reference field indices
 first_i=1;
@@ -1610,7 +1615,7 @@
         end
     end
-elseif strcmp(get(handles.OutputDirExt,'Visible'),'off')
-    msgbox_uvmat('ERROR',['no output file for Action ' ActionName ', use run mode = local']);% a output dir is needed for background option
-    return
+% elseif strcmp(get(handles.OutputDirExt,'Visible'),'off')
+%     msgbox_uvmat('ERROR',['no output file for Action ' ActionName ', use run mode = local']);% a output dir is needed for background option
+%     return
 else
     %% processing on a different session of the same computer (background) or cluster, create executable files
@@ -2168,36 +2173,47 @@
 
 %% definition of the directory containing the output files 
+SubDirOut='';%default
+OutputDirExt='series'; %default
+if isfield(ParamOut,'OutputDirExt')&&~isempty(ParamOut.OutputDirExt)
+    OutputDirExt=ParamOut.OutputDirExt;
+end
+set(handles.OutputDirExt,'String',OutputDirExt)
 OutputDirVisible='off';
-if isfield(ParamOut,'OutputDirExt')&&  ~isequal(ActionIndex,1)%&&~isempty(ParamOut.OutputDirExt)
-    OutputSubDirMode='all';%default
-    if isfield(ParamOut,'OutputSubDirMode')
-        OutputSubDirMode=ParamOut.OutputSubDirMode;
-    end
-    set(handles.OutputDirExt,'String',ParamOut.OutputDirExt)
-    OutputDirVisible='on';
-    SubDir=InputTable(1:end,2); %set of subdirectories sorted in alphabetical order
-    if strcmp(OutputSubDirMode,'last')
-        SubDirOut=SubDir{end};
-    else
+OutputSubDirMode='auto';%default
+if isfield(ParamOut,'OutputSubDirMode')
+    OutputSubDirMode=ParamOut.OutputSubDirMode;
+end
+switch OutputSubDirMode
+    case 'auto';%default
+        OutputDirVisible='on';
+        SubDir=InputTable(1:end,2); %set of subdirectories sorted in alphabetical order
         SubDirOut=SubDir{1};
-        if ~strcmp(OutputSubDirMode,'first')  && numel(SubDir)>1
+        if numel(SubDir)>1
             for ilist=2:numel(SubDir)
                 SubDirOut=[SubDirOut '-' SubDir{ilist}];
             end
         end
-    end
-    if isfield(ParamOut,'OutputSubDir')
-        SubDirOut=ParamOut.OutputSubDir;
-    end
-    set(handles.OutputSubDir,'String',SubDirOut)
-end
-
+    case 'first'
+        OutputDirVisible='on';
+        SubDirOut=InputTable{1,2}; %use the first subdir name (+OutputDirExt) as output  subdirectory
+    case 'last'
+        OutputDirVisible='on';
+        SubDirOut=InputTable{end,2}; %use the last subdir name (+OutputDirExt) as output  subdirectory
+end
+set(handles.OutputSubDir,'String',SubDirOut)
 set(handles.OutputDirExt,'Visible',OutputDirVisible)
 set(handles.OutputSubDir,'Visible',OutputDirVisible)
 set(handles.OutputDir_title,'Visible',OutputDirVisible)
-set(handles.RunMode,'Visible',OutputDirVisible)
-set(handles.ActionExt,'Visible',OutputDirVisible)
-set(handles.RunMode_title,'Visible',OutputDirVisible)
-set(handles.ActionExt_title,'Visible',OutputDirVisible)
+
+%% visibility of the run mode (local or background or cluster)
+if strcmp(OutputSubDirMode,'none')
+    RunModeVisible='off';% only local mode available if no output file is produced
+else
+     RunModeVisible='on';
+end
+set(handles.RunMode,'Visible',RunModeVisible)
+set(handles.ActionExt,'Visible',RunModeVisible)
+set(handles.RunMode_title,'Visible',RunModeVisible)
+set(handles.ActionExt_title,'Visible',RunModeVisible)
 
 
@@ -2952,5 +2968,5 @@
     RootPath=Param.InputTable{1,1};
     if ~isfield(Param,'OutputSubDir')   
-        msgbox_uvmat('ERROR','no directory defined for output files')
+        msgbox_uvmat('ERROR','no standard sub-directory definition for output files, use a browser to check the output')
         return
     end
