Index: trunk/src/series/aver_stat.m
===================================================================
--- trunk/src/series/aver_stat.m	(revision 470)
+++ trunk/src/series/aver_stat.m	(revision 474)
@@ -31,5 +31,5 @@
 %                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
 %    .OutputSubDir: name of the subdirectory for data outputs
-%    .OutputDir: directory for data outputs, including path
+%    .OutputDirExt: directory extension for data outputs
 %    .Action: .ActionName: name of the current activated function
 %             .ActionPath:   path of the current activated function
@@ -50,6 +50,5 @@
 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName
 if ~exist('Param','var') % case with no input parameter 
-    ParamOut={'NbViewMax';2;...% max nbre of input file series (default='' , no limitation)
-        'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
+    ParamOut={'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
         'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
         'NbSlice';'on'; ...%nbre of slices ('off' by default)
@@ -64,5 +63,5 @@
 end
 
-%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
+%%%%%%%%%%%%  STANDARD PART  %%%%%%%%%%%%
 %% select different modes,  RUN, parameter input, BATCH
 % BATCH  case: read the xml file for batch case
@@ -81,5 +80,6 @@
 end
 ParamOut=Param; %default output
-
+OutputDir=[Param.OutputSubDir Param.OutputDirExt];
+    
 %% root input file(s) and type
 RootPath=Param.InputTable(:,1);
@@ -88,16 +88,13 @@
 NomType=Param.InputTable(:,4);
 FileExt=Param.InputTable(:,5);
-
-% get the set of input file names (cell array filecell), and the lists of
-% input file or frame indices i1_series,i2_series,j1_series,j2_series
 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
-% filecell{iview,fileindex}: cell array representing the list of file names
+%%%%%%%%%%%%
+% The cell array filecell is the list of input file names, while
+% filecell{iview,fileindex}:
 %        iview: line in the table corresponding to a given file series
 %        fileindex: file index within  the file series, 
 % i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j 
 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
-% set of frame indices used for movie or multimage input 
-% numbers of slices and file indices
-
+%%%%%%%%%%%%
 NbSlice=1;%default
 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
@@ -140,7 +137,10 @@
 %% coordinate transform or other user defined transform
 transform_fct='';%default
-if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'TransformHandle')
-    transform_fct=Param.FieldTransform.TransformHandle;
-end
+if isfield(Param,'FieldTransform')
+    addpath(Param.FieldTransform.TransformPath)
+    transform_fct=str2func(Param.FieldTransform.TransformName);
+    rmpath(Param.FieldTransform.TransformPath)
+end
+
 %%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
  % EDIT FROM HERE
@@ -160,9 +160,6 @@
 end
 NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series
-if NbSlice~=nbfield_j
-    answer=msgbox_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]);
-    if ~strcmp(answer,'Yes')
-        return
-    end
+if checkrun==1
+    return % stop here for input checks
 end
 
@@ -185,32 +182,4 @@
 end
 
-%% Initiate output fields
-% %initiate the output structure as a copy of the first input one (reproduce fields)
-% [DataOut,ParamOut,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1);
-% if ~isempty(errormsg)
-%     msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg])
-%     return
-% end
-% time_1=[];
-% if isfield(DataOut,'Time')
-%     time_1=DataOut.Time(1);
-% end
-% if CheckNc{iview}
-%     if isempty(strcmp('Conventions',DataOut.ListGlobalAttribute))
-%         DataOut.ListGlobalAttribute=['Conventions' DataOut.ListGlobalAttribute];
-%     end
-%     DataOut.Conventions='uvmat';
-%     DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {Param.Action}];
-%     ActionKey='Action';
-%     while isfield(DataOut,ActionKey)
-%         ActionKey=[ActionKey '_1'];
-%     end
-%     DataOut.(ActionKey)=Param.Action;
-%     DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {ActionKey}];
-%     if isfield(DataOut,'Time')
-%         DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {'Time','Time_end'}];
-%     end
-% end
-
 %% MAIN LOOP ON SLICES
 %%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
@@ -219,10 +188,5 @@
     nbfiles=0;
     nbmissing=0;
-    
-    %initiate result fields
-%     for ivar=1:length(DataOut.ListVarName)
-%         DataOut.(DataOut.ListVarName{ivar})=0; % initialise all fields to zero
-%     end
-    
+
     %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
     for index=index_slice
@@ -350,5 +314,5 @@
     
     %writing the result file
-    OutputFile=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]);
+    OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]);
     if CheckImage{1} %case of images
         if isequal(FileInfo{1}.BitDepth,16)||(numel(FileInfo)==2 &&isequal(FileInfo{2}.BitDepth,16))
Index: trunk/src/series/merge_proj.m
===================================================================
--- trunk/src/series/merge_proj.m	(revision 470)
+++ trunk/src/series/merge_proj.m	(revision 474)
@@ -1,4 +1,4 @@
-%'merge_proj': project and concatene fieldsmerge_proj
-% can be used as a template for applying an operation (here projection and concateantion) on each field of an input series
+%'merge_proj': project and concatene fields
+% can be used as a template for applying an operation (here projection and concatenation) on each field of an input series
 %------------------------------------------------------------------------
 % function ParamOut=merge_proj(Param)
@@ -32,5 +32,5 @@
 %                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
 %    .OutputSubDir: name of the subdirectory for data outputs
-%    .OutputDir: directory for data outputs, including path
+%    .OutputDirExt: directory extension for data outputs
 %    .Action: .ActionName: name of the current activated function
 %             .ActionPath:   path of the current activated function
@@ -51,6 +51,5 @@
 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName
 if ~exist('Param','var') % case with no input parameter 
-    ParamOut={'NbViewMax';'';...% max nbre of input file series (default='' , no limitation)
-        'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
+    ParamOut={'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
         'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
         'NbSlice';'on'; ...%nbre of slices ('off' by default)
@@ -82,4 +81,5 @@
 end
 ParamOut=Param; %default output
+OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];
 
 %% root input file(s) and type
@@ -89,16 +89,13 @@
 NomType=Param.InputTable(:,4);
 FileExt=Param.InputTable(:,5);
-
-% get the set of input file names (cell array filecell), and the lists of
-% input file or frame indices i1_series,i2_series,j1_series,j2_series
 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
-% filecell{iview,fileindex}: cell array representing the list of file names
+%%%%%%%%%%%%
+% The cell array filecell is the list of input file names, while
+% filecell{iview,fileindex}:
 %        iview: line in the table corresponding to a given file series
 %        fileindex: file index within  the file series, 
 % i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j 
 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
-% set of frame indices used for movie or multimage input 
-% numbers of slices and file indices
-
+%%%%%%%%%%%%
 NbSlice=1;%default
 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
@@ -117,5 +114,5 @@
 for iview=1:nbview
     if ~exist(filecell{iview,1}','file')
-        msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'])
+        displ_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'],checkrun)
         return
     end
@@ -135,15 +132,17 @@
 if size(time,1)>1
     diff_time=max(max(diff(time)));
-    if diff_time>0
-        msgbox_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)])
+    if diff_time>0 
+        displ_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)],checkrun)
     end   
 end
-
 
 %% coordinate transform or other user defined transform
 transform_fct='';%default
-if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'TransformHandle')
-    transform_fct=Param.FieldTransform.TransformHandle;
-end
+if isfield(Param,'FieldTransform')
+    addpath(Param.FieldTransform.TransformPath)
+    transform_fct=str2func(Param.FieldTransform.TransformName);
+    rmpath(Param.FieldTransform.TransformPath)
+end
+
 %%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
  % EDIT FROM HERE
@@ -154,46 +153,22 @@
 elseif CheckNc{1}
     FileExtOut='.nc';% write result as .nc files for netcdf inputs
-else 
-    msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}])
+else
+    displ_uvmat('ERROR',['invalid file type input ' FileType{1}],checkrun)
     return
 end
 for iview=1:nbview
 	if ~isequal(CheckImage{iview},CheckImage{1})||~isequal(CheckNc{iview},CheckNc{1})
-        msgbox_uvmat('ERROR','input set of input series: need  either netcdf either image series')
+        displ_uvmat('ERROR','input set of input series: need  either netcdf either image series',checkrun)
     return
     end
 end
 NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series
+if checkrun==1
+    ParamOut.Specific=[];%no specific parameter
+    return %stop here for interactive input (option Param.Specific='?')
+end
 
 %% Set field names and velocity types
 %use Param.InputFields for all views
-
-%% Initiate output fields
-%initiate the output structure as a copy of the first input one (reproduce fields)
-[DataOut,tild,errormsg] = read_field(filecell{1,1},FileType{1},Param.InputFields,1);
-if ~isempty(errormsg)
-    msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg])
-    return
-end
-time_1=[];
-if isfield(DataOut,'Time')
-    time_1=DataOut.Time(1);
-end
-if CheckNc{iview}
-    if isempty(strcmp('Conventions',DataOut.ListGlobalAttribute))
-        DataOut.ListGlobalAttribute=['Conventions' DataOut.ListGlobalAttribute];
-    end
-    DataOut.Conventions='uvmat';
-    DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {Param.Action}];
-    ActionKey='Action';
-    while isfield(DataOut,ActionKey)
-        ActionKey=[ActionKey '_1'];
-    end
-    DataOut.(ActionKey)=Param.Action;
-    DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {ActionKey}];
-    if isfield(DataOut,'Time')
-        DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {'Time','Time_end'}];
-    end
-end
 
 %% MAIN LOOP ON SLICES
@@ -203,11 +178,5 @@
     nbfiles=0;
     nbmissing=0;
-    
-    %initiate result fields
-    
-    for ivar=1:length(DataOut.ListVarName)
-        DataOut.(DataOut.ListVarName{ivar})=0; % initialise all fields to zero
-    end
-    
+
     %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
     for index=index_slice
@@ -227,5 +196,6 @@
             [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index));
             if ~isempty(errormsg)
-                errormsg=['error of input reading: ' errormsg];
+                errormsg=['merge_proj/read_field/' errormsg];
+                display(errormsg)
                 break
             end
@@ -251,5 +221,5 @@
                 [Data{iview},errormsg]=proj_field(Data{iview},Param.ProjObject);
                 if ~isempty(errormsg)
-                    msgbox_uvmat('ERROR',['error in merge_proge/proj_field: ' errormsg])
+                    displ_uvmat('ERROR',['error in merge_proge/proj_field: ' errormsg],checkrun)
                     return
                 end
@@ -261,5 +231,5 @@
         MergeData=merge_field(Data);
         if isfield(MergeData,'Txt')
-            msgbox_uvmat('ERROR',MergeData.Txt)
+            displ_uvmat('ERROR',MergeData.Txt,checkrun)
             return
         end
@@ -288,5 +258,5 @@
             end
         end
-        OutputFile=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomType{1},i1,i2,j1,j2);
+        OutputFile=fullfile_uvmat(RootPath{1},OutputSubDir,RootFile{1},FileExtOut,NomType{1},i1,i2,j1,j2);
         
         % recording the merged field
@@ -387,5 +357,5 @@
     else
         if length(ivar_Y)~=1
-                msgbox_uvmat('ERROR','y coordinate missing in proj_field.m')
+                displ_uvmat('ERROR','y coordinate missing in proj_field.m',checkrun)
                 return
         end
Index: trunk/src/series/sub_background.m
===================================================================
--- trunk/src/series/sub_background.m	(revision 470)
+++ trunk/src/series/sub_background.m	(revision 474)
@@ -38,5 +38,5 @@
 %                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
 %    .OutputSubDir: name of the subdirectory for data outputs
-%    .OutputDir: directory for data outputs, including path
+%    .OutputDirExt: extension for the directory for data outputs
 %    .Action: .ActionName: name of the current activated function
 %             .ActionPath:   path of the current activated function
@@ -58,6 +58,5 @@
 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName
 if ~exist('Param','var') % case with no input parameter 
-    ParamOut={'NbViewMax';1;...% max nbre of input file series (default='' , no limitation)
-        'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
+    ParamOut={'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
         'WholeIndexRange';'on';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
         'NbSlice';'on'; ...%nbre of slices ('off' by default)
@@ -89,4 +88,5 @@
 end
 ParamOut=Param; %default output
+OutputDir=[Param.OutputSubDir Param.OutputDirExt];
 
 %% root input file(s) and type
@@ -96,16 +96,13 @@
 NomType=Param.InputTable(:,4);
 FileExt=Param.InputTable(:,5);
-
-% get the set of input file names (cell array filecell), and the lists of
-% input file or frame indices i1_series,i2_series,j1_series,j2_series
 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
-% filecell{iview,fileindex}: cell array representing the list of file names
+%%%%%%%%%%%%
+% The cell array filecell is the list of input file names, while
+% filecell{iview,fileindex}:
 %        iview: line in the table corresponding to a given file series
 %        fileindex: file index within  the file series, 
 % i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j 
 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
-% set of frame indices used for movie or multimage input 
-% numbers of slices and file indices
-
+%%%%%%%%%%%%
 NbSlice=1;%default
 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
@@ -340,5 +337,5 @@
             j1=j1_series{1}(ifile);
         end
-        newname=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
+        newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
         
         %write result file
@@ -390,5 +387,5 @@
                         j1=j1_series{1}(ifile);
                     end
-                    newname=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
+                    newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
                     %write result file
                     if ParamOut.Specific.CheckLevelTransform
@@ -424,5 +421,5 @@
             j1=j1_series{1}(ifile);
         end
-        newname=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
+        newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
         
         %write result file
Index: trunk/src/series/time_series.m
===================================================================
--- trunk/src/series/time_series.m	(revision 470)
+++ trunk/src/series/time_series.m	(revision 474)
@@ -31,5 +31,5 @@
 %                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
 %    .OutputSubDir: name of the subdirectory for data outputs
-%    .OutputDir: directory for data outputs, including path
+%    .OutputDirExt: directory extension for data outputs
 %    .Action: .ActionName: name of the current activated function
 %             .ActionPath:   path of the current activated function
@@ -50,6 +50,5 @@
 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName
 if ~exist('Param','var') % case with no input parameter 
-    ParamOut={'NbViewMax';2;...% max nbre of input file series (default='' , no limitation)
-        'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
+    ParamOut={'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
         'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
         'NbSlice';'on'; ...%nbre of slices ('off' by default)
@@ -81,4 +80,5 @@
 end
 ParamOut=Param; %default output
+OutputDir=[Param.OutputSubDir Param.OutputDirExt];
 
 %% root input file(s) and type
@@ -116,5 +116,5 @@
 for iview=1:nbview
     if ~exist(filecell{iview,1}','file')
-        msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'])
+        displ_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'],checkrun)
         return
     end
@@ -134,5 +134,5 @@
     diff_time=max(max(diff(time)));
     if diff_time>0
-        msgbox_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)])
+        displ_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)],checkrun)
     end   
 end
@@ -140,7 +140,10 @@
 %% coordinate transform or other user defined transform
 transform_fct='';%default
-if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'TransformHandle')
-    transform_fct=Param.FieldTransform.TransformHandle;
-end
+if isfield(Param,'FieldTransform')
+    addpath(Param.FieldTransform.TransformPath)
+    transform_fct=str2func(Param.FieldTransform.TransformName);
+    rmpath(Param.FieldTransform.TransformPath)
+end
+
 %%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
  % EDIT FROM HERE
@@ -152,18 +155,18 @@
     FileExtOut='.nc';% write result as .nc files for netcdf inputs
 else 
-    msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}])
+    displ_uvmat('ERROR',['invalid file type input ' FileType{1}],checkrun)
     return
 end
 if nbview==2 && ~isequal(CheckImage{1},CheckImage{2})
-        msgbox_uvmat('ERROR','input must be two image series or two netcdf file series')
+        displ_uvmat('ERROR','input must be two image series or two netcdf file series',checkrun)
     return
 end
 NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series
-if NbSlice~=nbfield_j
-    answer=msgbox_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]);
-    if ~strcmp(answer,'Yes')
-        return
-    end
-end
+% if NbSlice~=nbfield_j
+%     answer=_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]);
+%     if ~strcmp(answer,'Yes')
+%         return
+%     end
+% end
 
 %% Set field names and velocity types
@@ -211,5 +214,5 @@
 [DataOut,tild,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1);
 if ~isempty(errormsg)
-    msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg])
+    displ_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg],checkrun)
     return
 end
@@ -238,193 +241,159 @@
 nbmissing=0; %number of undetected files
 for i_slice=1:NbSlice
-    dt=[];
-    %%%%%%%%%%%%%%%%%%%%%%%%%%%%  LOOP ON FIELDS WITHIN  A SLICE
-    filecounter=0;
-    for ifile=i_slice:NbSlice:nbfield
+    index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice
+    nbfiles=0;
+    nbmissing=0;
+    
+    %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
+    for index=index_slice       
         if checkrun
-            update_waitbar(hseries.waitbar_frame,WaitbarPos,ifile/nbfield)
+            update_waitbar(hseries.waitbar_frame,WaitbarPos,index/(nbfield))
             stopstate=get(hseries.RUN,'BusyAction');
         else
             stopstate='queue';
         end
-        errormsg='';
+        
+        %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
+        Data=cell(1,nbview);%initiate the set Data
+        nbtime=0;
+        dt=[];
         if isequal(stopstate,'queue')% enable STOP command
             % loop on views (in case of multiple input series)
             for iview=1:nbview
-                filename=filecell{iview,ifile};
-               % filename=name_generator(filebase{iview},...
-                %    i1_series{iview}(ifile),j1_series{iview}(ifile),FileExt{iview},NomType{iview},1,i2_series{iview}(ifile),j2_series{iview}(ifile),SubDir{iview});
-                if exist(filename,'file')
-                    try
-                        Data{iview}=[]; %default
-                        if ~isequal(FileType{iview},'netcdf')
-                            Data{iview}.ListVarName={'A'};
-                            Data{iview}.AName='image';
-                            switch FileType{iview}
-                                case 'movie'
-                                    A=read(MovieObject{iview},i1_series{iview}(ifile));
-                                case 'avi'
-                                    mov=aviread(filename,i1_series{iview}(ifile));
-                                    A=frame2im(mov(1));
-                                case 'vol'
-                                    A=imread(filename);
-                                case 'multimage'
-                                    A=imread(filename,i1_series{iview}(ifile));
-                                case 'image'
-                                    A=imread(filename);
-                            end
-                            Data{iview}.ListVarName={'AY','AX','A'}; %
-                            npy=size(A,1);
-                            npx=size(A,2);
-                            nbcolor=size(A,3);
-                            if nbcolor==3
-                                Data{iview}.VarDimName={'AY','AX',{'AY','AX','rgb'}};
-                            else
-                                Data{iview}.VarDimName={'AY','AX',{'AY','AX'}};
-                            end
-                            Data{iview}.AY=[npy-0.5 0.5];
-                            Data{iview}.AX=[0.5 npx-0.5];
-                            Data{iview}.A=double(A);
-                            Data{iview}.CoordUnit='pixel';
-                        elseif testcivx
-                            [Data{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType);
-                            if ~isequal(FieldName,{''})
-                                Data{iview}=calc_field(FieldName,Data{iview});%calculate field (vort..)
-                            end
-                        else
-                            [Data{iview},var_detect]=nc2struct(filename,SubField.ListVarName); %read the corresponding input data
-                            Data{iview}.VarAttribute=SubField.VarAttribute;
-                        end
-                        if ~isempty(NbSlice_calib)  % z index
-                            Data{iview}.ZIndex=mod(i1_series{iview}(ifile)-1,NbSlice_calib{1})+1;
-                        end
-                    catch ME
-                        errormsg=ME.message;
+                % reading input file(s)
+                [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index));
+                if ~isempty(errormsg)
+                    errormsg=['time_series/read_field/' errormsg];
+                    display(errormsg)
+                    break
+                end
+                timeread(iview)=0;
+                if isfield(Data{iview},'Time')
+                    timeread(iview)=Data{iview}.Time;
+                    nbtime=nbtime+1;
+                end
+                if ~isempty(NbSlice_calib)
+                    Data{iview}.ZIndex=mod(i1_series{iview}(index)-1,NbSlice_calib{iview})+1;%Zindex for phys transform
+                end
+            end
+            % coordinate transform (or other user defined transform)
+            if ~isempty(transform_fct)
+                if nbview==2
+                    [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});
+                    if isempty(Data{2})
+                        Data(2)=[];
                     end
                 else
-                    errormsg=[filename ' is missing'];
-                end
-                if isempty(errormsg)
-                    % coordinate transform (or other user defined transform)
-                    if ~isempty(transform_fct)
-                        if nbview==2
-                            [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});
-                            if isempty(Data{2})
-                                Data(2)=[];
+                    Data{1}=transform_fct(Data{1},XmlData{1});
+                end
+            end
+            if length(Data)==2
+                [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields
+            else
+                Field=Data{1};
+            end
+            if Param.CheckObject
+                [Field,errormsg]=proj_field(Field,Param.ProjObject);
+            end
+            nbtime=nbtime+1;
+            
+            % initiate the time series at the first iteration
+            if nbtime==1
+                % stop program if the first field reading is in error
+                if ~isempty(errormsg)
+                    displ_uvmat('ERROR',['error in time_series/sub_field:' errormsg],checkrun)
+                    return
+                end
+                DataOut=Field;%default
+                DataOut.NbDim=Field.NbDim+1; %add the time dimension for plots
+                nbvar=length(Field.ListVarName);
+                if nbvar==0
+                    displ_uvmat('ERROR','no input variable selected in get_field',checkrun)
+                    return
+                end
+                testsum=2*ones(1,nbvar);%initiate flag for action on each variable
+                if isfield(Field,'VarAttribute') % look for coordinate and flag variables
+                    for ivar=1:nbvar
+                        if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role')
+                            var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable
+                            if isequal(var_role,'errorflag')
+                                displ_uvmat('ERROR','do not handle error flags in time series',checkrun)
+                                return
                             end
-                        else
-                            Data{1}=transform_fct(Data{1},XmlData{1});
+                            if isequal(var_role,'warnflag')
+                                testsum(ivar)=0;  % not recorded variable
+                                eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable
+                            end
+                            if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|...
+                                    isequal(var_role,'coord_z')|isequal(var_role,'coord')
+                                testsum(ivar)=1; %constant coordinates, record without time evolution
+                            end
+                        end
+                        % check whether the variable ivar is a dimension variable
+                        DimCell=Field.VarDimName{ivar};
+                        if ischar(DimCell)
+                            DimCell={DimCell};
+                        end
+                        if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables
+                            testsum(ivar)=1;
                         end
                     end
-                    if length(Data)==2
-                        [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields
+                end
+                for ivar=1:nbvar
+                    if testsum(ivar)==2
+                        eval(['DataOut.' Field.ListVarName{ivar} '=[];'])
+                    end
+                end
+                DataOut.ListVarName=[{'Time'} DataOut.ListVarName];
+            end
+            
+            % add data to the current field
+            for ivar=1:length(Field.ListVarName)
+                VarName=Field.ListVarName{ivar};
+                VarVal=Field.(VarName);
+                if testsum(ivar)==2% test for recorded variable
+                    if isempty(errormsg)
+                        if isequal(Param.ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode
+                            if isempty(VarVal)
+                                displ_uvmat('ERROR',['empty result at frame index ' num2str(i1_series{iview}(ifile))],checkrun)
+                                return
+                            end
+                            VarVal=mean(VarVal,1);
+                        end
+                        VarVal=shiftdim(VarVal,-1); %shift dimension
+                        DataOut.(VarName)=cat(1,DataOut.(VarName),VarVal);%concanete the current field to the time series
                     else
-                        Field=Data{1};
+                        DataOut.(VarName)=cat(1,DataOut.(VarName),0);% put each variable to 0 in case of input reading error
                     end
-                    if Param.CheckObject
-                        [Field,errormsg]=proj_field(Field,Param.ProjObject);
-                    end
-                end
-                filecounter=filecounter+1;
-                
-                % initiate the time series at the first iteration
-                if filecounter==1
-                    % stop program if the first field reading is in error
-                    if ~isempty(errormsg)
-                        msgbox_uvmat('ERROR',['error in time_series/sub_field:' errormsg])
+                elseif testsum(ivar)==1% variable representing fixed coordinates
+                    eval(['VarInit=DataOut.' VarName ';']);
+                    if isempty(errormsg) && ~isequal(VarVal,VarInit)
+                        displ_uvmat('ERROR',['time series requires constant coordinates ' VarName],checkrun)
                         return
                     end
-                    DataOut=Field;%default
-                    DataOut.NbDim=Field.NbDim+1; %add the time dimension for plots
-                    nbvar=length(Field.ListVarName);
-                    if nbvar==0
-                        msgbox_uvmat('ERROR','no input variable selected in get_field')
-                        return
-                    end
-                    testsum=2*ones(1,nbvar);%initiate flag for action on each variable
-                    if isfield(Field,'VarAttribute') % look for coordinate and flag variables
-                        for ivar=1:nbvar
-                            if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role')
-                                var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable
-                                if isequal(var_role,'errorflag')
-                                    msgbox_uvmat('ERROR','do not handle error flags in time series')
-                                    return
-                                end
-                                if isequal(var_role,'warnflag')
-                                    testsum(ivar)=0;  % not recorded variable
-                                    eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable
-                                end
-                                if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|...
-                                        isequal(var_role,'coord_z')|isequal(var_role,'coord')
-                                    testsum(ivar)=1; %constant coordinates, record without time evolution
-                                end
-                            end
-                            % check whether the variable ivar is a dimension variable
-                            DimCell=Field.VarDimName{ivar};
-                            if ischar(DimCell)
-                                DimCell={DimCell};
-                            end
-                            if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables
-                                testsum(ivar)=1;
-                            end
-                        end
-                    end
-                    for ivar=1:nbvar
-                        if testsum(ivar)==2
-                            eval(['DataOut.' Field.ListVarName{ivar} '=[];'])
-                        end
-                    end
-                    DataOut.ListVarName=[{'Time'} DataOut.ListVarName];
-                end
-                
-                % add data to the current field
-                for ivar=1:length(Field.ListVarName)
-                    VarName=Field.ListVarName{ivar};
-                    VarVal=Field.(VarName);
-                    if testsum(ivar)==2% test for recorded variable
-                        if isempty(errormsg)
-                            if isequal(Param.ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode
-                                if isempty(VarVal)
-                                    msgbox_uvmat('ERROR',['empty result at frame index ' num2str(i1_series{iview}(ifile))])
-                                    return
-                                end
-                                VarVal=mean(VarVal,1);
-                            end
-                            VarVal=shiftdim(VarVal,-1); %shift dimension
-                            DataOut.(VarName)=cat(1,DataOut.(VarName),VarVal);%concanete the current field to the time series
-                        else
-                            DataOut.(VarName)=cat(1,DataOut.(VarName),0);% put each variable to 0 in case of input reading error
-                        end
-                    elseif testsum(ivar)==1% variable representing fixed coordinates
-                        eval(['VarInit=DataOut.' VarName ';']);
-                        if isempty(errormsg) && ~isequal(VarVal,VarInit)
-                            msgbox_uvmat('ERROR',['time series requires constant coordinates ' VarName])
-                            return
-                        end
-                    end
-                end
-                
-                % record the time:
-                if isempty(time)% time read in ncfiles
-                    if isfield(Field,'Time')
-                        DataOut.Time(filecounter,1)=Field.Time;
-                    else
-                        DataOut.Time(filecounter,1)=ifile;%default
-                    end
-                else % time from ImaDoc prevails  TODO: correct 
-                  %  DataOut.Time(filecounter,1)=time{1}(i1_series{1})(ifile),j1_series{1}(ifile))+time(end,i2_series{end}(ifile),j2_series{end}(ifile)))/2;
-                  DataOut.Time(filecounter,1)=i1_series{1}(ifile);% TODO : generalise
-                end
-                
-                % record the number of missing input fields
-                if ~isempty(errormsg)
-                    nbmissing=nbmissing+1;
-                    display(['ifile=' num2str(ifile) ':' errormsg])
-                end
+                end
+            end
+            
+            % record the time:
+            if isempty(time)% time read in ncfiles
+                if isfield(Field,'Time')
+                    DataOut.Time(filecounter,1)=Field.Time;
+                else
+                    DataOut.Time(filecounter,1)=ifile;%default
+                end
+            else % time from ImaDoc prevails  TODO: correct
+                %  DataOut.Time(filecounter,1)=time{1}(i1_series{1})(ifile),j1_series{1}(ifile))+time(end,i2_series{end}(ifile),j2_series{end}(ifile)))/2;
+                DataOut.Time(filecounter,1)=i1_series{1}(ifile);% TODO : generalise
+            end
+            
+            % record the number of missing input fields
+            if ~isempty(errormsg)
+                nbmissing=nbmissing+1;
+                display(['ifile=' num2str(ifile) ':' errormsg])
             end
         end
     end
     %%%%%%% END OF LOOP WITHIN A SLICE
-   
+    
     %remove time for global attributes if exists
     Time_index=find(strcmp('Time',DataOut.ListGlobalAttribute));
@@ -438,5 +407,5 @@
     end
     
-    % add time dimension 
+    % add time dimension
     for ivar=1:length(Field.ListVarName)
         DimCell=Field.VarDimName(ivar);
@@ -469,15 +438,14 @@
     % display nbmissing
     if ~isequal(nbmissing,0)
-        msgbox_uvmat('WARNING',[num2str(nbmissing) ' files skipped: missing files or bad input, see command window display'])
+        displ_uvmat('WARNING',[num2str(nbmissing) ' files skipped: missing files or bad input, see command window display'],checkrun)
     end
     
     %name of result file
-%     filemean=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},'.nc','_1',i1_series{1}(i_slice));
-    OutputFile=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]);
+    OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]);
     errormsg=struct2nc(OutputFile,DataOut); %save result file
     if isempty(errormsg)
         display([OutputFile ' written'])
     else
-        msgbox_uvmat('ERROR',['error in Series/struct2nc: ' errormsg])
+        displ_uvmat('ERROR',['error in Series/struct2nc: ' errormsg],checkrun)
     end
 end
@@ -486,5 +454,7 @@
 figure
 haxes=axes;
+if checkrun
 plot_field(DataOut,haxes)
+end
 
 %% display the result file using the GUI get_field
