Index: /trunk/src/series/merge_proj.m
===================================================================
--- /trunk/src/series/merge_proj.m	(revision 738)
+++ /trunk/src/series/merge_proj.m	(revision 739)
@@ -57,6 +57,4 @@
     first_j=[];
     if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
-    last_j=[];
-    if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
     PairString='';
     if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
@@ -132,4 +130,8 @@
     end
 end
+if NbView >1 && max(cell2mat(CheckImage))>0 && ~isfield(Param,'ProjObject')
+    disp_uvmat('ERROR','projection on a common grid is needed to concatene images: use a Projection Object of type ''plane'' with ProjMode=''interp_lin''',checkrun)
+    return
+end
 
 %% calibration data and timing: read the ImaDoc files
@@ -225,5 +227,5 @@
         [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index));
         if ~isempty(errormsg)
-            disp(['ERROR in merge_proj/read_field/' errormsg])
+            disp_uvmat(['ERROR in merge_proj/read_field/' errormsg],checkrun)
             return
         end
@@ -253,5 +255,5 @@
             [Data{iview},errormsg]=proj_field(Data{iview},Param.ProjObject);
             if ~isempty(errormsg)
-                disp(['ERROR in merge_proge/proj_field: ' errormsg])
+                disp_uvmat(['ERROR in merge_proge/proj_field: ' errormsg],checkrun)
                 return
             end
@@ -266,7 +268,7 @@
 
     %% merge the NbView fields
-    MergeData=merge_field(Data);
-    if isfield(MergeData,'Txt')
-        disp(MergeData.Txt);
+    [MergeData,errormsg]=merge_field(Data);
+    if ~isempty(errormsg)
+        disp_uvmat('ERROR',errormsg,checkrun);
         return
     end
@@ -361,7 +363,7 @@
         error=struct2nc(OutputFile,MergeData);%save result file
         if isempty(error)
-            display(['output file ' OutputFile ' written'])
+            disp(['output file ' OutputFile ' written'])
         else
-            display(error)
+            disp(error)
         end
     end
@@ -371,5 +373,5 @@
 %'merge_field': concatene fields
 %------------------------------------------------------------------------
-function MergeData=merge_field(Data)
+function [MergeData,errormsg]=merge_field(Data)
 %% default output
 if isempty(Data)||~iscell(Data)
@@ -377,5 +379,5 @@
     return
 end
-error=0;
+errormsg='';
 MergeData=Data{1};% merged field= first field by default, reproduces the glabal attributes of the first field
 NbView=length(Data);
@@ -386,4 +388,7 @@
 %% group the variables (fields of 'Data') in cells of variables with the same dimensions
 [CellInfo,NbDim,errormsg]=find_field_cells(Data{1});
+if ~isempty(errormsg)
+    return
+end
 
 %LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
@@ -417,5 +422,8 @@
                             MergeData.(VarName)=Data{1}.(VarName);% correct the field of MergeData
                             NbAver=~check_bad;% initiate NbAver: the nbre of good data for each point
-                        else
+                        elseif size(Data{iview}.(VarName))~=size(MergeData.(VarName))
+                            errormsg='sizes of the input matrices do not agree, need to interpolate on a common grid using a projection object';
+                            return
+                        else                     
                             MergeData.(VarName)=MergeData.(VarName) + Data{iview}.(VarName);%add data
                             NbAver=NbAver + ~check_bad;% add 1 for good data, 0 else
