Index: /trunk/src/PARAM.xml.default
===================================================================
--- /trunk/src/PARAM.xml.default	(revision 500)
+++ /trunk/src/PARAM.xml.default	(revision 501)
@@ -2,5 +2,4 @@
 <UvmatParam>
 <RunParam>
-<MaxCivProcesses>20</MaxCivProcesses>
 <RunTime>${MCRROOT712}</RunTime>
 <CivBin>bin/civ<!--binary for the new civx version (relative or
@@ -10,10 +9,7 @@
 <Civ2Bin>bin/civ2<!--binary for civ2 (relative or absolute path)
 --></Civ2Bin>
-<CivmBin>civ_matlab.sh<!--binary from compilation of civ_matlab.
-m (relative or absolute path)--></CivmBin>
 <Civ3D3CBin>bin/civ3d3c</Civ3D3CBin>
 <FixBin>bin/fix_flag</FixBin>
 <PatchBin>bin/patch_up</PatchBin>
-<PatchNewBin></PatchNewBin>
 </RunParam>
 <BatchParam>
@@ -23,10 +19,7 @@
 <Civ1Bin>bin/civ1</Civ1Bin>
 <Civ2Bin>bin/civ2</Civ2Bin>
-<CivmBin>civ_matlab.sh<!--binary from compilation of civ_matlab.
-m (relative or absolute path)--></CivmBin>
 <Civ3D3CBin>bin/civ3d3c</Civ3D3CBin>
 <FixBin>bin/fix_flag</FixBin>
 <PatchBin>bin/patch_up</PatchBin>
-<PatchNewBin></PatchNewBin>
 </BatchParam>
 <SchemaPath>XML_SCHEMAS <!--directory of xml schemas(relative or absolut
Index: /trunk/src/calc_field.m
===================================================================
--- /trunk/src/calc_field.m	(revision 500)
+++ /trunk/src/calc_field.m	(revision 501)
@@ -117,5 +117,5 @@
             end
         end
-        coord_x=XMin:DataIn.Mesh:XMax;
+        coord_x=XMin:DataIn.Mesh:XMax;% increase the recommanded mesh to  visualisation
         coord_y=YMin:DataIn.Mesh:YMax;
 %         npx=length(coord_x);
Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 500)
+++ /trunk/src/civ.m	(revision 501)
@@ -337,5 +337,12 @@
 ind_opening=0;%default
 if strcmp(ExtInput,'.xml')
-    Param=xml2struct(fileinput);
+    %reinitialise menus
+        set(handles.ListPairMode,'Value',1)
+    set(handles.ListPairMode,'String',{''})
+    set(handles.ListPairCiv1,'Value',1)
+    set(handles.ListPairCiv1,'String',{''})
+        set(handles.ListPairCiv2,'Value',1)
+    set(handles.ListPairCiv2,'String',{''}) 
+    Param=xml2struct(fileinput);  %read parameters from the xml input file
     fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file 
     return
@@ -611,13 +618,23 @@
 %% set the civ options depending on the input file content when a nc file has been opened
 ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'};
-if ind_opening~=0
-    for index = 1:ind_opening
+if ind_opening==0
+    for index=1:numel(ListOptions)
+        checkbox(index)=get(handles.(ListOptions{index}),'Value');
+    end
+    for index=1:max(1,max(find(checkbox)))
+        set(handles.(ListOptions{index}),'Value',1)% select all operations starting from CIV1
+    end
+else
+    for index = 1:min(ind_opening,5)
         set(handles.(ListOptions{index}),'value',0)
     end
-end
-for index = ind_opening+2:6
-    set(handles.(ListOptions{index}),'value',0)
-end
-set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1)
+    set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1)
+    for index = ind_opening+2:6
+        set(handles.(ListOptions{index}),'value',0)
+    end
+end
+%list_operation={'CheckCiv1','CheckFix1','CheckPatch1','CheckCiv2','CheckFix2','CheckPatch2'};
+
+%set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1)
 update_CivOptions(handles,ind_opening)
 
@@ -1093,5 +1110,4 @@
     Param.xml.FixBin=fullfile('bin','fix_flag');
     Param.xml.PatchBin=fullfile('bin','patch_up');
-    Param.xml.CivmBin=fullfile('bin','civ_matlab');
 end
 if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster
@@ -1111,5 +1127,5 @@
         Param.xml.FixBin=fullfile('bin','fix_flag');
         Param.xml.PatchBin=fullfile('bin','patch_up');
-        Param.xml.CivmBin=fullfile('bin','civ_matlab');
+   %     Param.xml.CivmBin=fullfile('bin','civ_matlab');
         Param.xml.BatchMode='oar';% TODO : allow choice for sge
     end
@@ -1122,7 +1138,7 @@
         Param.xml.FixBin=fullfile('bin','fix_flag');
         Param.xml.PatchBin=fullfile('bin','patch_up');
-        Param.xml.CivmBin=fullfile('bin','civ_matlab');
-    end
-end
+    end
+end
+%Param.xml.CivmBin=fullfile('bin','civ_matlab');
 
 %% check if the binaries exist : to move in civ_opening
@@ -1133,6 +1149,6 @@
     case 'CivAll'% desactivated option
         binary_list={'Civ'};
-    case 'civ_matlab.sh'% compiled version of civ_matlab 
-        binary_list={'CivmBin'};         
+%     case 'civ_matlab.sh'% compiled version of civ_matlab 
+%         binary_list={'CivmBin'};         
 end
 for bin_name=binary_list %loop on the list of binaries
@@ -1153,5 +1169,6 @@
                 cd(currentdir);
             else
-                errormsg=['path ' path ' for binaries defined in PARAM.xml does not exist'];
+                errormsg=['path ' path ' for binaries specified in PARAM.xml does not exist'];
+                return
             end          
         else  %look for the full path if the file name has been defined with a relative path in PARAM.xm
@@ -1160,12 +1177,13 @@
                 Param.xml.(bin_name{1})=fullname;
             else
-                errormsg=['Binary ' Param.xml.(bin_name{1}) ' defined in PARAM.xml does not exist'];
-            end
-        end
-    end
-end
-if ~isempty(errormsg)
-    if strcmp(Param.Program,'civ_matlab.sh')
-        errormsg=[{errormsg}; {'run compile_functions.m to create it by compiling civ_matlab.m'}];
+                errormsg=['Binary ' Param.xml.(bin_name{1}) ' specified in PARAM.xml does not exist'];
+                return
+            end
+        end
+    end
+end
+if strcmp(Param.Program,'civ_matlab.sh')
+    if ~exist(fullfile(path_civ,'civ_matlab.sh'),'file')
+        errormsg=[{'no file civ_matlab.sh found'}; {'run compile_functions.m to create it by compiling civ_matlab.m'}];
     end
     return
@@ -1188,5 +1206,10 @@
 %% create subfolders for log, cmx, nml, xml, bat
 RootBat=fileparts(filecell.nc.civ1{1,1});
-dir_list={'0_BAT','0_CMX','0_XML','0_LOG'};
+switch(Param.Program)
+    case {'CivX','CivAll'}
+dir_list={'0_BAT','0_CMX','0_LOG'};
+    case {'civ_matlab','civ_matlab.sh'}
+        dir_list={'0_BAT','0_XML'};
+end
 for k=1:length(dir_list)
     if ~exist(fullfile(RootBat,dir_list{k}),'dir')
Index: /trunk/src/find_field_indices.m
===================================================================
--- /trunk/src/find_field_indices.m	(revision 500)
+++ /trunk/src/find_field_indices.m	(revision 501)
@@ -117,5 +117,5 @@
 
 %% role of variables
-Role=mat2cell(blanks(nbvar),1,ones(1,nbvar));%initialize a cell array of nbvar blanks
+Role=num2cell(blanks(nbvar));%initialize a cell array of nbvar blanks
 Role=regexprep(Role,' ','scalar'); % Role set to 'scalar' by default
 if isfield(Data,'VarAttribute')
@@ -129,14 +129,13 @@
 %% loop on the list of variables, group them by common dimensions
 for ivar=1:nbvar
+    if ischar(Data.VarDimName{ivar})
+        Data.VarDimName{ivar}=Data.VarDimName(ivar);%transform char chain into cell
+    end
     DimCell=Data.VarDimName{ivar}; %dimensions associated with the variable #ivar
-    if ischar(DimCell)
-        DimCell={DimCell};
-        Data.VarDimName{ivar}={Data.VarDimName{ivar}};%transform char chain into cell
-    end
     testnewcell=1;
     for icell_prev=1:numel(CellVarIndex)%detect whether the dimensions of ivar fit with an existing cell
         PrevVarIndex=CellVarIndex{icell_prev};%list of variable indices in cell # icell_prev
-        PrevDimName=Data.VarDimName{PrevVarIndex(1)};%list of corresponding variable names
-        if isequal(PrevDimName,DimCell)
+        PrevDimCell=Data.VarDimName{PrevVarIndex(1)};%list of corresponding variable names
+        if isequal(PrevDimCell,DimCell)
             CellVarIndex{icell_prev}=[CellVarIndex{icell_prev} ivar];% add variable index #ivar to the cell #icell_prev
             testnewcell=0; %existing cell detected
@@ -146,15 +145,25 @@
     if testnewcell
         icell=icell+1;
-        CellVarIndex{icell}=ivar;%put the current variabl index in the new cell 
+        CellVarIndex{icell}=ivar;%put the current variable index in the new cell 
+        NbDim(icell)=numel(DimCell);%default
     end
    
     %look for dimension variables
-    if numel(DimCell)==1% if the variable has a single dimension 
-        if strcmp(DimCell{1},Data.ListVarName{ivar}) || strcmp(Role{ivar},'dimvar')
-            ivardim=ivardim+1;
-            VarDimIndex(ivardim)=ivar;%index of the variable
-            VarDimName{ivardim}=DimCell{1};%name of the dimension
-        end
-    end
+%     if numel(DimCell)==1% if the variable has a single dimension 
+%         if strcmp(DimCell{1},Data.ListVarName{ivar}) %|| strcmp(Role{ivar},'dimvar')
+%             ivardim=ivardim+1;
+%             VarDimIndex(ivardim)=ivar;%index of the variable
+%             VarDimName{ivardim}=DimCell{1};%name of the dimension
+%         end
+%     end
+end
+
+%% find dimension variables
+checksinglecell=cellfun(@numel,CellVarIndex)==1 & NbDim==1;% find isolated cells with a single dimension
+ind_dim_var_cell=find(checksinglecell);
+%CoordType(ind_dim_var_cell)='dim_var';% to be used in output
+for icoord=1:numel(ind_dim_var_cell)
+VarDimIndex(icoord)=CellVarIndex{ind_dim_var_cell(icoord)};
+VarDimName{icoord}=Data.VarDimName{VarDimIndex(icoord)}{1};
 end
 
@@ -162,5 +171,5 @@
 ListRole={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','vector_x_tps','vector_y_tps','warnflag','errorflag',...
     'ancillary','image','color','discrete','scalar','coord_tps'};% rmq vector_x_tps and vector_y_tps to be replaced by vector_x and vector_y
-NbDim=zeros(size(CellVarIndex));%default
+% NbDim=zeros(size(CellVarIndex));%default
 
 for ilist=1:numel(ListRole)
@@ -171,6 +180,6 @@
     VarType.subrange_tps=[];
     VarType.nbsites_tps=[];
+    select=zeros(1,numel(VarType.coord_tps));
     for ifield=1:numel(VarType.coord_tps)
-        select(ifield)=0;
         DimCell=Data.VarDimName{VarType.coord_tps(ifield)};
         if numel(DimCell)==3
@@ -194,4 +203,7 @@
 CellVarType=cell(1,length(CellVarIndex));
 for icell=1:length(CellVarIndex)
+    if checksinglecell(icell)
+        continue
+    end
     VarIndex=CellVarIndex{icell};%set of variable indices with the same dim
     check_remove=0;
@@ -212,4 +224,11 @@
             return
         end
+        % case of x cordinate marked as a dimension variable (var name=dimension name)
+        if isempty(CellVarType{icell}.coord_x)
+            var_dim_index=find(strcmp(DimCell{1},Data.ListVarName(VarIndex)));
+            if ~isempty(var_dim_index)
+                CellVarType{icell}.coord_x=VarIndex(var_dim_index);
+            end
+        end         
         if numel(CellVarType{icell}.errorflag)>1
             errormsg='multiply defined error flag in the same cell';
@@ -239,10 +258,14 @@
         if  ~test_coord && ~isempty(VarDimName)
             for idim=1:numel(DimCell)   %loop on the dimensions of the variables in cell #icell
-                for ivardim=1:numel(VarDimName)
-                    if strcmp(VarDimName{ivardim},DimCell{idim})
-                        coord(idim)=VarDimIndex(ivardim);
-                        break
-                    end
+                ind_coord=find(strcmp(DimCell{idim},VarDimName));
+                if ~isempty(ind_coord)
+                    coord(idim)=VarDimIndex(ind_coord);
                 end
+%                 for ivardim=1:numel(VarDimName)
+%                     if strcmp(VarDimName{ivardim},DimCell{idim})
+%                         coord(idim)=VarDimIndex(ivardim);
+%                         break
+%                     end
+%                 end
             end
             NbDim(icell)=numel(find(coord));
Index: /trunk/src/plot_field.m
===================================================================
--- /trunk/src/plot_field.m	(revision 500)
+++ /trunk/src/plot_field.m	(revision 501)
@@ -132,15 +132,15 @@
     end
 end
-index_1D=find(NbDim==1);
+index_1D=find(NbDim==1&~cellfun(@isempty,VarType));
 index_0D=find(NbDim==0);
 %remove coordinates variables from 1D plot
-if ~isempty(index_2D)
-    for ivar=1:length(index_1D)
-        if isequal(CellVarIndex{index_1D(ivar)},VarType{index_1D(ivar)}.coord)
-            index_1D(ivar)=0;
-        end
-    end
-    index_1D=index_1D(index_1D>0);
-end
+% if ~isempty(index_2D)
+%     for ivar=1:length(index_1D)
+%         if isequal(CellVarIndex{index_1D(ivar)},VarType{index_1D(ivar)}.coord)
+%             index_1D(ivar)=0;
+%         end
+%     end
+%     index_1D=index_1D(index_1D>0);
+% end
 
 %% test axes and figure
@@ -346,4 +346,7 @@
 %loop on input  fields
 for icell=1:length(CellVarIndex)
+    if isempty(VarType{icell})% coordiante variable
+        continue
+    end
     VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list data.ListVarName
     if ~isempty(VarType{icell}.coord_x)
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 500)
+++ /trunk/src/uvmat.m	(revision 501)
@@ -2379,5 +2379,5 @@
 end
 if (check_tps ||check_proj_tps)&&~isfield(Field{1},'Coord_tps')
-    SubDomain=1500; %default, estimated nbre of vectors in a subdomain used for tps
+    SubDomain=1000; %default, estimated nbre of vectors in a subdomain used for tps
     if isfield(Field{1},'SubDomain')
         SubDomain=Field{1}.SubDomain;% 
