Index: trunk/src/series/civ_series.m
===================================================================
--- trunk/src/series/civ_series.m	(revision 911)
+++ trunk/src/series/civ_series.m	(revision 912)
@@ -356,6 +356,28 @@
             end
         end
-        if ~CheckOverwrite && exist(ncfile,'file')          
-        continue% skip iteration if the mode overwrite is desactivated and the result file already exists
+        ncfile_out=ncfile;% by default 
+        if isfield (Param.ActionInput,'Civ2')
+            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
+            if strcmp(Param.ActionInput.ListCompareMode,'PIV')
+                ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);
+            else % displacement
+                ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_civ2,[],j2_civ2);
+            end
+        end
+        if ~CheckOverwrite && exist(ncfile_out,'file')
+            disp(['existing output file ' ncfile_out ' already exists, skip to next field'])
+            continue% skip iteration if the mode overwrite is desactivated and the result file already exists
         end
     end
@@ -582,18 +604,18 @@
             par_civ2.ImageA=[];
             par_civ2.ImageB=[];
-            i1=i1_series_Civ2(ifield);
-            i2=i1;
-            if ~isempty(i2_series_Civ2)
-                i2=i2_series_Civ2(ifield);
-            end
-            j1=1;
-            if ~isempty(j1_series_Civ2)
-                j1=j1_series_Civ2(ifield);
-            end
-            j2=j1;
-            if ~isempty(j2_series_Civ2)
-                j2=j2_series_Civ2(ifield);
-            end
-            ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1,[],j1);
+%             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);
             
             if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2(ifield))
@@ -602,5 +624,5 @@
                 [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A_Civ2,FileType_A,VideoObject_A,FrameIndex_A_Civ2(ifield));
             end
-            ImageName_B_Civ2=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2,[],j2);
+            ImageName_B_Civ2=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_civ2,[],j2_civ2);
             if strcmp(ImageName_B_Civ2,ImageName_B) && isequal(FrameIndex_B_Civ1(ifield),FrameIndex_B_Civ2)
                 par_civ2.ImageB=par_civ1.ImageB;
@@ -608,9 +630,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=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1,i2,j1,j2);
-            else % displacement
-                ncfile=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;
@@ -712,5 +734,5 @@
                 Civ2_Dt=1;
             else
-                Civ2_Dt=time(i2+1,j2+1)-time(i1+1,j1+1);
+                Civ2_Dt=time(i2_civ2+1,j2_civ2+1)-time(i1_civ2+1,j1_civ2+1);
             end
         end
@@ -737,8 +759,8 @@
             Data.Civ2_ImageB=ImageName_B;
              if strcmp(Param.ActionInput.ListCompareMode,'displacement')
-                Data.Civ2_Time=time(i2+1,j2+1);% the time is the time of the secodn image
+                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+1,j2+1)+time(i1+1,j1+1))/2;
+            Data.Civ2_Time=(time(i2_civ2+1,j2_civ2+1)+time(i1_civ2+1,j1_civ2+1))/2;
             Data.Civ2_Dt=Civ2_Dt;
              end
@@ -863,7 +885,7 @@
     %% write result in a netcdf file if requested
     if CheckOutputFile
-        errormsg=struct2nc(ncfile,Data);
+        errormsg=struct2nc(ncfile_out,Data);
         if isempty(errormsg)
-            disp([ncfile ' written'])
+            disp([ncfile_out ' written'])
         else
             disp(errormsg)
