Index: /trunk/src/browse_data.m
===================================================================
--- /trunk/src/browse_data.m	(revision 1069)
+++ /trunk/src/browse_data.m	(revision 1070)
@@ -25,5 +25,5 @@
 function varargout = browse_data(varargin)
 
-% Last Modified by GUIDE v2.5 08-Jul-2019 23:32:39
+% Last Modified by GUIDE v2.5 11-Jul-2019 18:52:06
 
 % Begin initialization code - DO NOT EDIT
@@ -35,5 +35,5 @@
     'gui_LayoutFcn',  [] , ...
     'gui_Callback',   []);
-if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once'))
+if nargin && ischar(varargin{1}) 
     gui_State.gui_Callback = str2func(varargin{1});
 end
@@ -45,4 +45,5 @@
 end
 % End initialization code - DO NOT EDIT
+
 
 %------------------------------------------------------------------------
@@ -146,4 +147,17 @@
 varargout{1} = handles.output;
 %%%%%%%%%%%%%%%%%%delete(handles.browse_data)
+
+%------------------------------------------------------------------------
+% --- Executes on button press in SourceDir.
+function SourceDir_Callback(hObject, eventdata, handles)
+SourceDir=get(handles.SourceDir,'String');
+ListExp=get(handles.ListExperiments,'String');
+ListExp=ListExp(get(handles.ListExperiments,'Value'));
+errormsg=scan_campaign(handles,SourceDir,ListExp);
+if ~isempty(errormsg)
+    msgbox_uvmat('ERROR',errormsg)
+    return
+end
+%------------------------------------------------------------------------
 
 %------------------------------------------------------------------------
@@ -397,7 +411,12 @@
 
 %------------------------------------------------------------------------
-% Provide a list to display
+% Provide the list (ListFilesTot) to display in DataSeries with the selected indices
 %------------------------------------------------------------------------
 function [ListFilesTot,indices]=list_dir_3(SourceDir,ListDir,ListSub,ListSubSub,check_fix)
+% INPUT:
+%SourceDir: path to the displayed directories
+%ListDir: list of file and folder names under SourceDir (column 'Experiments')
+%ListSub: list of file and folder in the second column 'Devices')
+%ListSubSub: prvious list of file and folder in the third column 'DataSeries', used to mark the selected indices
 ListFilesTot={};
 for ilist=1:numel(ListDir)
@@ -410,9 +429,15 @@
                 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
                 ListFiles=ListCells(1,:);
+                check_xml=~cellfun('isempty',regexp(ListFiles,'(\.xml|~)$'));% detect non xml files and files not marked by ~
                 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
+                nbfiles=numel(find(~check_xml & ~check_dir));% number of non xml files
+                check_dir=check_dir & cellfun('isempty', regexp(ListFiles,'^(-|\.|\+/\.)'));% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
                 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
-                cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
-                check_keep=cellfun('isempty', cell_remove);
-                ListFilesTot=[ListFilesTot (ListFiles(check_keep))];
+                %cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )         
+                ListFiles=ListFiles(check_dir | check_xml);           
+                ListFilesTot=[ListFilesTot ListFiles];
+                if nbfiles>0
+                    ListFilesTot=[ListFilesTot {[num2str(nbfiles) ' files']}];
+                end
             end
         end
@@ -426,4 +451,8 @@
     for ilist=1:numel(ListSubSub)
         index=find(strcmp(ListSubSub{ilist},ListFilesTot));
+        if check_fix && isempty(index)
+            ListFilesTot=[ListFilesTot {['---' ListSubSub{ilist}]}];
+            index=numel(ListFilesTot);
+        end
         indices=[indices index];
     end
@@ -676,5 +705,5 @@
 set(handles.ListDevices,'Value',list_val);%replace Devices by DataSeries
 
-[ListFiles,indices]=list_dir_3(SourceDirNew,ListDevices(DeviceIndices),DataSeries(list_val),[]);
+[ListFiles,indices]=list_dir_3(SourceDirNew,ListDevices(DeviceIndices),DataSeries(list_val),[],0);
 set(handles.DataSeries,'String',ListFiles)
 set(handles.DataSeries,'Value',indices)% initialise the menu selection with the folder defined by the input
@@ -777,2 +806,12 @@
 %     set(handles.DataSeries,'Value',Index)
 % end
+
+
+% --- Executes when user attempts to close browse_data.
+function browse_data_CloseRequestFcn(hObject, eventdata, handles)
+% hObject    handle to browse_data (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hint: delete(hObject) closes the figure
+delete(hObject);
Index: /trunk/src/dir_uvmat.m
===================================================================
--- /trunk/src/dir_uvmat.m	(revision 1069)
+++ /trunk/src/dir_uvmat.m	(revision 1070)
@@ -28,5 +28,10 @@
 
 function [ListFiles,errormsg] = dir_uvmat(DirName)
+ListFiles=[];
 errormsg='';
+if ~ischar(DirName)
+    errormsg='the function dir_uvmat needs a character string input';
+    return
+end
 if regexp(DirName,'^http://')
     % OpeNDAP case - read catalog.xml file
@@ -35,5 +40,4 @@
     str=urlread(catalog);
     catch ME
-        ListFiles=[];
         errormsg=ME.message;
         return
Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 1069)
+++ /trunk/src/series.m	(revision 1070)
@@ -612,4 +612,11 @@
 function REFRESH_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
+check_input_file_series(handles)
+
+%% enable field and veltype menus, in accordance with the current action
+ActionInput_Callback([],[], handles)
+
+
+function check_input_file_series(handles)
 InputTable=get(handles.InputTable,'Data');
 set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch'
@@ -676,6 +683,4 @@
 set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch'
 
-%% enable field and veltype menus, in accordance with the current action
-ActionInput_Callback([],[], handles)
 
 
@@ -1661,18 +1666,21 @@
         Param.InputTable(:,1)=ListPath(:,iexp);
         Param.InputTable(:,2)=ListSubdir(:,iexp);
-        if size(Param.InputTable,1)==1% case of single input line
-        Param.OutputSubDir=ListSubdir{iexp};
-        end
-        set(handles.InputTable,'Data',Param.InputTable)
-%         set(handles.OutputSubDir,'String',ListSubdir{iexp})
+        OutputSubDir=unique(ListSubdir(:,iexp));
+        Param.OutputSubDir=OutputSubDir{1};
+        if numel(OutputSubDir)>1% case 
+            for iout=2:numel(OutputSubDir)
+                Param.OutputSubDir=[Param.OutputSubDir '-' OutputSubDir{iout}];
+            end               
+        end       
     end
     [xx,ExpName]=fileparts(Param.InputTable{1,1});
     Param.IndexRange.first_i=str2num(get(handles.num_first_i,'String'));%reset the firrst_i and last_i for multiple experiments, modified by the splitting into NbProcess
     Param.IndexRange.last_i=str2num(get(handles.num_last_i,'String'));
-    %% create the output data directory if needed
+    
+    %% create the output data directory if needed, after chcking its existence
     OutputDir='';
     answer='';
     if isfield(Param,'OutputSubDir')% possibly update the output dir if it already exists
-        SubDirOut=[get(handles.OutputSubDir,'String') Param.OutputDirExt];
+        SubDirOut=[Param.OutputSubDir Param.OutputDirExt];
         SubDirOutNew=SubDirOut;
         detect=exist(fullfile(Param.InputTable{1,1},SubDirOutNew),'dir'); % test if  the dir  already exist
@@ -1708,8 +1716,7 @@
             continue
         end
-        Param.OutputDirExt=regexprep(SubDirOutNew,Param.OutputSubDir,'');
+        Param.OutputDirExt=regexprep(SubDirOutNew,['^' Param.OutputSubDir],'');
         Param.OutputRootFile=Param.InputTable{1,3}; % the first sorted RootFile taken for output
-        set(handles.OutputDirExt,'String',Param.OutputDirExt)
-        OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]) % full name (with path) of output directory
+        OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]); % full name (with path) of output directory
         if check_create    % create output directory if it does not exist
             [tild,msg1]=mkdir(OutputDir);
@@ -1722,4 +1729,12 @@
     elseif isfield(Param,'ActionInput')&&isfield(Param.ActionInput,'LogPath')% custom definition of the output dir
         OutputDir=Param.ActionInput.LogPath;
+    end
+    
+    set(handles.OutputSubDir,'String',Param.OutputSubDir)
+    set(handles.OutputDirExt,'String',Param.OutputDirExt)
+    drawnow
+    if get(handles.Replicate,'Value')
+        set(handles.InputTable,'Data',Param.InputTable)
+        check_input_file_series(handles)
     end
     DirXml=fullfile(OutputDir,'0_XML');
@@ -2209,7 +2224,5 @@
 end
 set(handles.Replicate,'BackgroundColor',[0 1 0])
-if NbExp>1
-    set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta (input file features need to be updated)
-end
+
 %------------------------------------------------------------------------
 function STOP_Callback(hObject, eventdata, handles)
@@ -3816,6 +3829,12 @@
 % --- Executes on button press in MonitorCluster.
 function MonitorCluster_Callback(hObject, eventdata, handles)
-disp('format: R/W=run/wait, time lapsed, R=nbre of cores,W=walltime')
-system('oarstat |grep N=UVmat')% check the list of jobs launched with uvmat
+
+[rr,ss]=system('oarstat |grep N=UVmat');% check the list of jobs launched with uvmat
+if isempty(ss)
+   disp( 'no job presently submitted with uvmat')
+else
+    disp('format: R/W=run/wait, time lapsed, R=nbre of cores,W=walltime')
+    disp(ss)
+end
 
 
