Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 918)
+++ /trunk/src/series.m	(revision 919)
@@ -1764,6 +1764,7 @@
 
 
-%% direct processing on the current Matlab session
-% if strcmp (RunMode,'local')
+%% direct processing on the current Matlab session or creation of command files
+filexml=cell(1,NbProcess);% initialisation of the names of the files containing the processing parameters
+extxml=cell(1,NbProcess); % initialisation of the set of labels used for the files documenting each process
 for iprocess=1:NbProcess
     if ~strcmp(get(handles.RUN,'BusyAction'),'queue')% allow for STOP action
@@ -1773,5 +1774,5 @@
     if isempty(Param.IndexRange.NbSlice)
         Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;
-%         Param.IndexRange.first_i=ref_i(1+(iprocess-1)*BlockLength);
+        %         Param.IndexRange.first_i=ref_i(1+(iprocess-1)*BlockLength);
         if Param.IndexRange.first_i>last_i
             NbProcess=iprocess-1;% leave the loop, we are at the end of the calculation
@@ -1782,6 +1783,6 @@
         Param.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1);
     else %multislices (then incr_i is not empty)
-%         Param.IndexRange.first_i= first_i+incr_i*(iprocess-1);
-%         Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice;
+        %         Param.IndexRange.first_i= first_i+incr_i*(iprocess-1);
+        %         Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice;
         Param.IndexRange.first_i= first_i+iprocess-1;
         Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice;
@@ -1809,6 +1810,13 @@
         extxml{iprocess}=fullfile_uvmat('','',Param.InputTable{1,3},'.xml',OutputNomType,...
             Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
-        filexml{iprocess}=fullfile(OutputDir,'0_XML',extxml{iprocess})
-        save(t, filexml{iprocess});% save the xml file containing the processing parameters
+        filexml{iprocess}=fullfile(OutputDir,'0_XML',extxml{iprocess});
+        try
+            save(t, filexml{iprocess});% save the xml file containing the processing parameters
+        catch ME
+            if ~strcmp (RunMode,'local')
+                errormsg=['error writting ' filexml{iprocess} ': ' ME.message];
+                return
+            end
+        end
     end
     if strcmp (RunMode,'local')
@@ -1827,4 +1835,5 @@
     end
 end
+
 if ~strcmp (RunMode,'local') && ~strcmp(RunMode,'python')
     %% processing on a different session of the same computer (background) or cluster, create executable files
Index: /trunk/src/set_grid.m
===================================================================
--- /trunk/src/set_grid.m	(revision 918)
+++ /trunk/src/set_grid.m	(revision 919)
@@ -194,7 +194,7 @@
 YA=grid_pix_A(:,2);
 unitcolumn=32*ones(size(XA));
-Xchar=num2str(XA,2);
+Xchar=num2str(XA,'%1.1f');% write x coordinate in px, rounded at the first decimal
 blanc=char(unitcolumn);
-Ychar=num2str(YA,2);
+Ychar=num2str(YA,'%1.1f');% write y coordinate in px, rounded at the first decimal
 tete=['1 ' num2str(nbpointsA(1))];
 txt=[Xchar blanc Ychar];
Index: /trunk/src/struct2nc.m
===================================================================
--- /trunk/src/struct2nc.m	(revision 918)
+++ /trunk/src/struct2nc.m	(revision 919)
@@ -49,5 +49,6 @@
     return
 end
-%check the validity of the input field structure
+
+%% check the validity of the input field structure
 [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data);
 if ~isempty(errormsg)
@@ -56,11 +57,12 @@
 end
 ListVarName=Data.ListVarName;
-%nc=netcdf.create(flname,'NC_CLOBBER');%,'clobber'); %create the netcdf file with name flname 
+
+%% create the netcdf file with name flname in format NETCDF4
 cmode = netcdf.getConstant('NETCDF4');
 cmode = bitor(cmode, netcdf.getConstant('CLASSIC_MODEL'));
 cmode = bitor(cmode, netcdf.getConstant('CLOBBER'));
-nc = netcdf.create(flname, cmode) 
-
-%write global constants
+nc = netcdf.create(flname, cmode); 
+
+%% write global constants
 if isfield(Data,'ListGlobalAttribute')
     keys=Data.ListGlobalAttribute;
@@ -84,5 +86,6 @@
     end
 end
-%create dimensions
+
+%% create the dimensions
 dimid=zeros(1,length(ListDimName));
 for idim=1:length(ListDimName)
@@ -95,12 +98,30 @@
     testattr=1;
 end
-varid=zeros(1,length(Data.ListVarName));
+
+
+%% create the variables
+varid=nan(1,length(Data.ListVarName));
 for ivar=1:length(ListVarName)
-    varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},'nc_double',dimid(VarDimIndex{ivar}));%define variable  
-end
- %write variable attributes
+    if isfield(Data,ListVarName{ivar})
+        VarClass=class(Data.(ListVarName{ivar}));
+        VarType='';
+        switch VarClass
+            case {'single','double'}
+                VarType='nc_float'; % store all floating reals as single
+            case {'uint8','int16','uint16','int32','uint32','int64','uint64'}
+                VarType='nc_int';
+            case  'logical'
+                VarType='nc_byte';
+        end
+        if ~isempty(VarType)
+            varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},VarType,dimid(VarDimIndex{ivar}));%define variable
+        end
+    end
+end
+
+%% write variable attributes
 if testattr
     for ivar=1:min(numel(VarAttribute),numel(ListVarName))  
-        if isstruct(VarAttribute{ivar})
+        if isstruct(VarAttribute{ivar}) && ~isnan(varid(ivar))
             attr_names=fields(VarAttribute{ivar});
             for iattr=1:length(attr_names)
@@ -114,9 +135,10 @@
 end
 netcdf.endDef(nc); %put in data mode
+
+%% fill the variables with input data
 for ivar=1:length(ListVarName)
-    if isfield(Data,ListVarName{ivar})
+    if ~isnan(varid(ivar))
         VarVal=Data.(ListVarName{ivar}); 
         %varval=values of the current variable 
-%        VarDimIndex=Data.VarDimIndex{ivar}; %indices of the variable dimensions in the list of dimensions
         VarDimName=Data.VarDimName{ivar};
         if ischar(VarDimName)
@@ -126,9 +148,5 @@
         testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2);% case of a coordinate defined on a regular mesh by the first and last values.
         testline=isequal(length(siz),2) && isequal(siz(1),1)&& isequal(siz(2), DimValue(VarDimIndex{ivar}));%matlab vector
-        testcolumn=isequal(length(siz),2) && isequal(siz(1), DimValue(VarDimIndex{ivar}))&& isequal(siz(2),1);%matlab column vector
-%             if ~testrange && ~testline && ~testcolumn && ~isequal(siz,DimValue(VarDimIndex))
-%                 errormsg=['wrong dimensions declared for ' ListVarName{ivar} ' in struct2nc.m'];
-%                 break
-%             end 
+        %testcolumn=isequal(length(siz),2) && isequal(siz(1), DimValue(VarDimIndex{ivar}))&& isequal(siz(2),1);%matlab column vector
         if testline || testrange
             if testrange
Index: /trunk/src/struct2xml.m
===================================================================
--- /trunk/src/struct2xml.m	(revision 918)
+++ /trunk/src/struct2xml.m	(revision 919)
@@ -1,15 +1,20 @@
-%'struct2xml': transform a matlab structure to a xml tree.
+%'struct2xml': transforms a matlab structure to a xml tree.
 %--------------------------------------------------------------
+%
 % each field with char string or num vector is transformed into a corresponding  xml element
 % each field with a matrix containing n lines is transformed into a xml element repeated n times 
-% WARNING: PROBLEM WITH HIERARCHICAL structures
+% each substructure of the input matlab structure is translateed into a subtree in the xml object
+% it is also possible to append a subtree to an existing xml object t
+%
+% t=struct2xml(Object,t,root_uid)
 %%%%%%%%%%%%%%%%%%%%%%%
 % OUTPUT:
 % t: xmltree reproducing the structure of Object
 % type 'save(t)' to visualize the xml text and save(filename,t) to save it in a file
+% to set the title tag of the file, type t=set(t,1,'name','titletag')
 %
 % INPUT:
 %  Object: matlab structure, possibly hierarchical
-%  t: optional input xml tree in which a new branch needs to be appended
+%  t: optional input xml tree in which a subtree needs to be appended
 %  root_uid: optional uid of the xml element under which the new subtree must be appended
 
