Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 996)
+++ /trunk/src/series.m	(revision 997)
@@ -1455,4 +1455,17 @@
 % --- called by RUN_Callback
 %------------------------------------------------------------------------
+% The calculations are launched in three different ways:
+% RunMode='local': calculation on the local Matlab session, will prevent other actions during that time.
+% RunMode='background': calculation on the local computer, but in a new Matlab session (with no graphic output).
+% RunMode='cluster': calculations dispatched in a cluster, using a managing system, 'oar, 'sge, or 'sgb'.
+% In the latter case, the calculation is split in 'packets' of i index (all j indices are contained in a single packet).
+% This splitting is possible only if the different calculations in the series are independent. Otherwise the action 
+% function imposes a number of processes NbSlice in input, for instance NbSlice=1 for a time series.
+% If NbSlice is not imposed, the splitting in packets (jobs) is determined
+% so that a job is optimum length AdvisedJobCPUTime), and the total job number in any case smaller
+% than MaxJobNumber (these parameters are defined in the file series.xml in
+% accordance with the management strategy for the cluster). The jobs are
+% dispatched in parallel into NbCore processors by the cluster managing system. 
+
 function errormsg=launch_action(handles)
 errormsg=''; % default
@@ -1568,18 +1581,19 @@
         NbCore=1; % no need to split the calculation
     case 'cluster_oar'
-        NbCoreDefault=SeriesData.OarParam.NbCoreDefault;%proposed number of cores (for cluster)
-            if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled)
+        %proposed number of cores to reserve in the cluster
+        NbCoreAdvised=SeriesData.SeriesParam.OarParam.NbCoreAdvised;
+        NbCoreMax=SeriesData.SeriesParam.OarParam.NbCoreMax;
+        if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled)
             warning_string=', preferably use .sh option to save Matlab licences';
-            else
-                warning_string='';
-            end
-            answer=inputdlg({['Number of cores (max 36)' warning_string],'extra oar options'},'oarsub parameter',1,{num2str(NbCoreDefault),''});
-            if isempty(answer)
-                                errormsg='Action launch interrupted by user';
-                return
-            end
-            NbCore=str2double(answer{1});
-            extra_oar=answer{2};
- %       end
+        else
+            warning_string=')';
+        end
+        answer=inputdlg({['Number of cores (max ' num2str(NbCoreMax) warning_string],'extra oar options'},'oarsub parameter',1,{num2str(NbCoreAdvised),''});
+        if isempty(answer)
+            errormsg='Action launch interrupted by user';
+            return
+        end
+        NbCore=str2double(answer{1});
+        extra_oar=answer{2};
     case {'cluster_pbs', 'cluster_sge', 'cluster_qstat_unknown'}
         if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled)
@@ -1722,12 +1736,14 @@
 switch RunMode
     case {'cluster_oar','cluster_pbs','cluster_sge','cluster_qstat_unknown'}
+        JobNumberMax=SeriesData.SeriesParam.OarParam.JobNumberMax;
+        JobCPUTimeAdvised=SeriesData.SeriesParam.OarParam.JobCPUTimeAdvised;
         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
+            BlockLength= ceil(JobCPUTimeAdvised/(CPUTime*nbfield_j)); % iterations are grouped in sets with length BlockLength  such that the typical CPU time of a job is MinJobNumber.
+            BlockLength=max(BlockLength,ceil(numel(ref_i)/JobNumberMax)); % possibly increase the BlockLength to have less than MaxJobNumber 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
-            NbCore=min(NbCore,NbProcess); % reduces the number of cores if it exceeds the number of processes
-        end
+        end
+        NbCore=min(NbCore,NbProcess); % reduces the number of cores if it exceeds the number of processes
     otherwise
         if ~isempty(Param.IndexRange.NbSlice)
@@ -1858,13 +1874,10 @@
     filelog_global=fullfile(OutputDir,'0_LOG',filelog_global);
 
-    for iprocess=1:NbProcess
-        
-        %create the executable file
-        
+    for iprocess=1:NbProcess    
+        %create the executable file       
         batch_file_list{iprocess}=fullfile(OutputDir,'0_EXE',regexprep(extxml{iprocess},'.xml$',ExeExt));
         
         % set the log file name
-        filelog{iprocess}=fullfile(OutputDir,'0_LOG',regexprep(extxml{iprocess},'.xml$','.log'));
-        
+        filelog{iprocess}=fullfile(OutputDir,'0_LOG',regexprep(extxml{iprocess},'.xml$','.log'));      
     end
 end
@@ -2001,7 +2014,8 @@
         % 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)
+        WallTimeMax=SeriesData.SeriesParam.OarParam.WallTimeMax;
+        JobTime=CPUTime*BlockLength*nbfield_j; % estimated CPU 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);
+        WallTimeTotal=min(WallTimeMax,4*JobTime/60);
         %disp(['WallTimeTotal: ' num2str(WallTimeTotal) ' hours'])
         % estimated time of an individual job (in min), with a margin of error
@@ -2314,4 +2328,5 @@
 %% Activate the Action fct to adapt the configuration of the GUI series and bring specific parameters in SeriesData
 Param=read_GUI_series(handles); % read the parameters from the GUI series
+Param.Action.RUN=0;
 ParamOut=h_fun(Param); % run the selected Action function to get the relevant input
 
@@ -2527,5 +2542,5 @@
     set(handles.NbSlice_title,'Visible','off')
 end
-if isnumeric(ParamOut.NbSlice)
+if isfield(ParamOut,'NbSlice') && isnumeric(ParamOut.NbSlice)
     set(handles.num_NbSlice,'String',num2str(ParamOut.NbSlice))
     set(handles.num_NbSlice,'Enable','off'); % NbSlice set by the activation of the Action function
Index: /trunk/src/series.xml.default
===================================================================
--- /trunk/src/series.xml.default	(revision 996)
+++ /trunk/src/series.xml.default	(revision 997)
@@ -3,8 +3,10 @@
    <DiskQuotaCmd>quota -s -g -A</DiskQuotaCmd> 
 <OarParam>
-   <NbCoreDefault>16</NbCoreDefault><!--proposed default number of parallel cores for a job -->
-   <MinEstimatedCPUTime unit="minute">20</MinEstimatedCPUTime><!--used to group the iterations into jobs of sufficient CPU time-->
-   <MaxJobNumber>500</MaxJobNumber><!--maximum number of jobs allowed (will group the iterations to fit in)-->
-   <JobStatCmd>oarstat |grep N=UVmat</JobStatCmd>   
+  <NbCoreAdvised>16</NbCoreAdvised><!--proposed default number of parallel cores attributed for the computations -->
+  <NbCoreMax>36</NbCoreMax><!--maximum number of cores allowed for the computations -->
+  <JobCPUTimeAdvised unit="minute">20</JobCPUTimeAdvised><!--used to group the iterations into jobs of sufficient CPU time-->
+  <JobNumberMax>500</JobNumberMax><!--maximum number of jobs allowed (will group the iterations to fit in)-->
+  <WallTimeMax unit="hour">23</WallTimeMax> <!--maximum allowed time for a job -->  
+  <JobStatCmd>oarstat |grep N=UVmat</JobStatCmd> <!--command to know the number of active and waiting job launches-->  
 </OarParam>
 <SgeParam>
Index: /trunk/src/series/check_data_files.m
===================================================================
--- /trunk/src/series/check_data_files.m	(revision 996)
+++ /trunk/src/series/check_data_files.m	(revision 997)
@@ -52,4 +52,5 @@
 function ParamOut=check_data_files(Param)
 
+ParamOut=[];
 %% input preparation mode (no RUN)
 if isstruct(Param) && isequal(Param.Action.RUN,0)
Index: /trunk/src/series/civ_series.m
===================================================================
--- /trunk/src/series/civ_series.m	(revision 996)
+++ /trunk/src/series/civ_series.m	(revision 997)
@@ -224,68 +224,58 @@
     
     %% check the first image pair
-    try
+%     try
         if Param.ActionInput.CheckCiv1% Civ1 is performed
-            first_ima=1;
-            ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1),[],j1_series_Civ1(1));
-            if checkrun 
-                if ~exist(ImageName_A,'file')
-                disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun)
-                return
-                end
-            else
-%                 for ifile=1:numel(i1_series_Civ1)
-%                     if 
-            end
-            [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A);
-            FileType_A=FileInfo_A.FileType;
-            if strcmp(FileInfo_A.FileType,'netcdf')
-                FieldName_A=Param.InputFields.FieldName;
-                [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A});
-                par_civ1.ImageA=DataIn.(FieldName_A);
-            else
-                [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(1));
-            end
-            ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1),[],j2_series_Civ1(1));
-            if ~exist(ImageName_B,'file')
-                disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun)
-                return
-            end
-            [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B);
-            FileType_B=FileInfo_B.FileType;
-            if strcmp(FileInfo_B.FileType,'netcdf')
-                FieldName_B=Param.InputFields.FieldName;
-                [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B});
-                par_civ1.ImageB=DataIn.(FieldName_B);
-            else
-                [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(1));
-            end
+%             ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1),[],j1_series_Civ1(1));
+%             [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A);
+%             FileType_A=FileInfo_A.FileType;
+%             if strcmp(FileInfo_A.FileType,'netcdf')
+%                 FieldName_A=Param.InputFields.FieldName;
+%                 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A});
+%                 par_civ1.ImageA=DataIn.(FieldName_A);
+%             else
+%                 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(1));
+%             end
+%             ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1),[],j2_series_Civ1(1));
+%             if ~exist(ImageName_B,'file')
+%                 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun)
+%                 return
+%             end
+%             [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B);
+%             FileType_B=FileInfo_B.FileType;
+%             if strcmp(FileInfo_B.FileType,'netcdf')
+%                 FieldName_B=Param.InputFields.FieldName;
+%                 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B});
+%                 par_civ1.ImageB=DataIn.(FieldName_B);
+%             else
+%                 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(1));
+%             end
             NbField=numel(i1_series_Civ1);
         elseif Param.ActionInput.CheckCiv2 % Civ2 is performed without Civ1
-            ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ2(1),[],j1_series_Civ2(1));
-            if ~exist(ImageName_A,'file')
-                disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun)
-                return
-            end
-            [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A);
-            FileType_A=FileInfo_A.FileType;
-            [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileInfo_A.FileType,VideoObject_A,FrameIndex_A_Civ2(1));
-            ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ2(1),[],j2_series_Civ2(1));
-            if ~exist(ImageName_B,'file')
-                disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun)
-                return
-            end
-            [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B);
-            FileType_B=FileInfo_B.FileType;
-            [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2(1));
+%             ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ2(1),[],j1_series_Civ2(1));
+%             if ~exist(ImageName_A,'file')
+%                 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun)
+%                 return
+%             end
+%             [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A);
+%             FileType_A=FileInfo_A.FileType;
+%             [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileInfo_A.FileType,VideoObject_A,FrameIndex_A_Civ2(1));
+%             ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ2(1),[],j2_series_Civ2(1));
+%             if ~exist(ImageName_B,'file')
+%                 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun)
+%                 return
+%             end
+%             [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B);
+%             FileType_B=FileInfo_B.FileType;
+%             [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2(1));
             NbField=numel(i1_series_Civ2);
         else
             NbField=numel(i1_series_Civ1);% no image used (only fix or patch) TO CHECK
         end
-    catch ME
-        if ~isempty(ME.message)
-            disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun)
-            return
-        end
-    end
+%     catch ME
+%         if ~isempty(ME.message)
+%             disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun)
+%             return
+%         end
+%     end
     
     
@@ -326,30 +316,12 @@
         end
     end
-    if isempty(Time) && ~isempty(find(strcmp(FileType_A,{'mmreader','video','cine_phantom'})))% case of video input
-        Time=zeros(FileInfo_A.NumberOfFrames+1,2);
-        Time(:,2)=(0:1/FileInfo_A.FrameRate:(FileInfo_A.NumberOfFrames)/FileInfo_A.FrameRate)';
-        TimeSource='video';
-        ColorType='truecolor';
-    end
-    if isempty(Time)% Time = index i +0.001 index j by default
-        %MinIndex_i=min(i1_series_Civ1);
-        MaxIndex_i=max(i2_series_Civ1);
-        %MinIndex_j=min(j1_series_Civ1);
-        MaxIndex_j=max(j2_series_Civ1);
-        Time=(1:MaxIndex_i)'*ones(1,MaxIndex_j);
-        Time=Time+0.001*ones(MaxIndex_i,1)*(1:MaxIndex_j);
-        Time=[zeros(1,MaxIndex_j);Time];% insert a first line of zeros
-        Time=[zeros(MaxIndex_i+1,1) Time];% insert a first column of zeros
-    end
-    
-    if length(FileInfo_A) >1 %case of image with multiple frames
-        nbfield=length(FileInfo_A);
-        nbfield_j=1;
-    end
+   
+
 end
 
 %%%%% MAIN LOOP %%%%%%
 maskname='';% initiate the mask name
-tic;
+FileType_A='';
+FileType_B='';
 CheckOverwrite=1;%default
 if isfield(Param,'CheckOverwrite')
@@ -357,4 +329,5 @@
 end
 for ifield=1:NbField
+    tic
     if ~isempty(RUNHandle)% update the waitbar in interactive mode with GUI series  (checkrun=1)
         update_waitbar(WaitbarHandle,ifield/NbField)
@@ -382,5 +355,5 @@
             end
         end
-        ncfile_out=ncfile;% by default 
+        ncfile_out=ncfile;% by default
         if isfield (Param.ActionInput,'Civ2')
             i1_civ2=i1_series_Civ2(ifield);
@@ -412,5 +385,5 @@
     if isfield (Param.ActionInput,'Civ1')
         if CheckInputFile
-        disp('civ1 started')
+            disp('civ1 started')
         end
         par_civ1=Param.ActionInput.Civ1;
@@ -418,17 +391,47 @@
             try
                 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield));
-                if strcmp(FileInfo_A.FileType,'netcdf')% case of input images in format netcdf
+                if strcmp(FileExt_A,'.nc')% case of input images in format netcdf
                     FieldName_A=Param.InputFields.FieldName;
                     [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A});
                     par_civ1.ImageA=DataIn.(FieldName_A);
                 else % usual image formats for image A
+                    if isempty(FileType_A)
+                        [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A);
+                        FileType_A=FileInfo_A.FileType;
+                        if isempty(Time) && ~isempty(find(strcmp(FileType_A,{'mmreader','video','cine_phantom'})))% case of video input
+                            Time=zeros(FileInfo_A.NumberOfFrames+1,2);
+                            Time(:,2)=(0:1/FileInfo_A.FrameRate:(FileInfo_A.NumberOfFrames)/FileInfo_A.FrameRate)';
+                            TimeSource='video';
+                            ColorType='truecolor';
+                        end
+                        if ~isempty(FileType_A) && isempty(Time)% Time = index i +0.001 index j by default
+                            MaxIndex_i=max(i2_series_Civ1);
+                            MaxIndex_j=max(j2_series_Civ1);
+                            Time=(1:MaxIndex_i)'*ones(1,MaxIndex_j);
+                            Time=Time+0.001*ones(MaxIndex_i,1)*(1:MaxIndex_j);
+                            Time=[zeros(1,MaxIndex_j);Time];% insert a first line of zeros
+                            Time=[zeros(MaxIndex_i+1,1) Time];% insert a first column of zeros
+                        end
+                    end
+                    if ~exist(ImageName_A,'file')
+                        disp([ImageName_A ' missing'])
+                        continue
+                    end
                     [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield));
                 end
                 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield));
-                if strcmp(FileInfo_B.FileType,'netcdf') % case of input images in format netcdf
+                if strcmp(FileExt_B,'.nc') % case of input images in format netcdf
                     FieldName_B=Param.InputFields.FieldName;
                     [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B});
                     par_civ1.ImageB=DataIn.(FieldName_B);
                 else % usual image formats for image B
+                    if isempty(FileType_B)
+                        [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B);
+                        FileType_B=FileInfo_B.FileType;
+                    end
+                    if ~exist(ImageName_B,'file')
+                        disp([ImageName_B ' missing'])
+                        continue
+                    end
                     [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield));
                 end
@@ -465,6 +468,6 @@
                 Data.Civ1_Dt=1;% Time interval is 1, to yield displacement instead of velocity=displacement/Dt at reading
             else
-            Data.Civ1_Time=(Time(i2+1,j2+1)+Time(i1+1,j1+1))/2;% the Time is the Time at the middle of the image pair
-            Data.Civ1_Dt=Time(i2+1,j2+1)-Time(i1+1,j1+1);
+                Data.Civ1_Time=(Time(i2+1,j2+1)+Time(i1+1,j1+1))/2;% the Time is the Time at the middle of the image pair
+                Data.Civ1_Dt=Time(i2+1,j2+1)-Time(i1+1,j1+1);
             end
             for ilist=1:length(list_param)
@@ -555,5 +558,5 @@
     %% Fix1
     if isfield (Param.ActionInput,'Fix1')
-         disp('fix1 started')
+        disp('fix1 started')
         if ~isfield (Param.ActionInput,'Civ1')% if we use existing Civ1, remove previous data beyond Civ1
             Fix1_attr=find(strcmp('Fix1',Data.ListGlobalAttribute));
@@ -630,17 +633,17 @@
             par_civ2.ImageA=[];
             par_civ2.ImageB=[];
-%             i1_civ2=i1_series_Civ2(ifield);
-%             i2_civ2=i1_civ2;
-%             if ~isempty(i2_series_Civ2)
-%                 i2_civ2=i2_series_Civ2(ifield);
-%             end
-%             j1_civ2=1;
-%             if ~isempty(j1_series_Civ2)
-%                 j1_civ2=j1_series_Civ2(ifield);
-%             end
-%             j2_civ2=i1_civ2;
-%             if ~isempty(j2_series_Civ2)
-%                 j2_civ2=j2_series_Civ2(ifield);
-%             end
+            %             i1_civ2=i1_series_Civ2(ifield);
+            %             i2_civ2=i1_civ2;
+            %             if ~isempty(i2_series_Civ2)
+            %                 i2_civ2=i2_series_Civ2(ifield);
+            %             end
+            %             j1_civ2=1;
+            %             if ~isempty(j1_series_Civ2)
+            %                 j1_civ2=j1_series_Civ2(ifield);
+            %             end
+            %             j2_civ2=i1_civ2;
+            %             if ~isempty(j2_series_Civ2)
+            %                 j2_civ2=j2_series_Civ2(ifield);
+            %             end
             ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_civ2,[],j1_civ2);
             
@@ -656,9 +659,9 @@
                 [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B_Civ2,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield));
             end
-%             if strcmp(Param.ActionInput.ListCompareMode,'PIV')
-%                 ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1,i2,j1,j2);
-%             else % displacement
-%                 ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2,[],j2);
-%             end
+            %             if strcmp(Param.ActionInput.ListCompareMode,'PIV')
+            %                 ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1,i2,j1,j2);
+            %             else % displacement
+            %                 ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2,[],j2);
+            %             end
             par_civ2.ImageWidth=FileInfo_A.Width;
             par_civ2.ImageHeight=FileInfo_A.Height;
@@ -784,11 +787,11 @@
             Data.Civ2_ImageA=ImageName_A;
             Data.Civ2_ImageB=ImageName_B;
-             if strcmp(Param.ActionInput.ListCompareMode,'displacement')
+            if strcmp(Param.ActionInput.ListCompareMode,'displacement')
                 Data.Civ2_Time=Time(i2_civ2+1,j2_civ2+1);% the Time is the Time of the secodn image
                 Data.Civ2_Dt=1;% Time interval is 1, to yield displacement instead of velocity=displacement/Dt at reading
-             else
-            Data.Civ2_Time=(Time(i2_civ2+1,j2_civ2+1)+Time(i1_civ2+1,j1_civ2+1))/2;
-            Data.Civ2_Dt=Civ2_Dt;
-             end
+            else
+                Data.Civ2_Time=(Time(i2_civ2+1,j2_civ2+1)+Time(i1_civ2+1,j1_civ2+1))/2;
+                Data.Civ2_Dt=Civ2_Dt;
+            end
         end
         for ilist=1:length(list_param)
@@ -822,5 +825,5 @@
                 disp_uvmat('ERROR',errormsg,checkrun)
                 return
-            end         
+            end
         elseif isfield(Param,'Civ2_X')% use Civ2 data as input in Param (test mode)
             Data.ListGlobalAttribute={};
@@ -893,6 +896,6 @@
         Data.VarAttribute{nbvar+6}.Role='vector_x';
         Data.VarAttribute{nbvar+7}.Role='vector_y';
-        Data.Civ2_U_smooth=Data.Civ2_U; 
-        Data.Civ2_V_smooth=Data.Civ2_V; 
+        Data.Civ2_U_smooth=Data.Civ2_U;
+        Data.Civ2_V_smooth=Data.Civ2_V;
         if isfield(Data,'Civ2_FF')
             ind_good=find(Data.Civ2_FF==0);
@@ -1034,6 +1037,6 @@
     end
     check_undefined=(par_civ.Mask<200 & par_civ.Mask>=20 );
-%     par_civ.ImageA(check_undefined)=0;% put image A to zero (i.e. the min image value) in the undefined  area
-%     par_civ.ImageB(check_undefined)=0;% put image B to zero (i.e. the min image value) in the undefined  area
+    %     par_civ.ImageA(check_undefined)=0;% put image A to zero (i.e. the min image value) in the undefined  area
+    %     par_civ.ImageB(check_undefined)=0;% put image B to zero (i.e. the min image value) in the undefined  area
 end
 
Index: /trunk/src/xml2struct.m
===================================================================
--- /trunk/src/xml2struct.m	(revision 996)
+++ /trunk/src/xml2struct.m	(revision 997)
@@ -64,6 +64,10 @@
     end
 else
+    try
     ss=convert(t);%transform the xmltree object into a Matlab structure.
     s=convert_string(ss);
+    catch ME
+        errormsg=ME.message;
+    end
 end
 
