Index: trunk/src/read_field.m
===================================================================
--- trunk/src/read_field.m	(revision 681)
+++ trunk/src/read_field.m	(revision 684)
@@ -50,5 +50,5 @@
     end
     check_colorvar=zeros(size(InputField));
-    if isfield(ParamIn,'ColorVar')
+    if isfield(ParamIn,'ColorVar')&&~isempty(ParamIn.ColorVar)
         InputField=[ParamIn.FieldName {ParamIn.ColorVar}];
         check_colorvar(numel(InputField))=1;
@@ -71,12 +71,15 @@
         Role={};
         ProjModeRequest={};
+        ListInputField={};
+        ListOperator={};
         checkU=0;
         checkV=0;
         for ilist=1:numel(InputField)
             r=regexp(InputField{ilist},'(?<Operator>(^vec|^norm))\((?<UName>.+),(?<VName>.+)\)$','names');
-            Operator='';
             if isempty(r)%  no operator used
                 if isempty(find(strcmp(InputField{ilist},ListVar)))
-                ListVar=[ListVar InputField(ilist)];%append the variable name if not already in the list
+                    ListVar=[ListVar InputField(ilist)];%append the variable name if not already in the list
+                    ListInputField=[ListInputField InputField(ilist)];
+                    ListOperator=[ListOperator {''}];
                 end
                 if check_colorvar(ilist)
@@ -88,5 +91,5 @@
                 end
             else  % an operator 'vec' or 'norm' is used
-                Operator=r.Operator;
+                %Operator=r.Operator;
                 if ~check_colorvar(ilist) && strcmp(r.Operator,'norm')
                     ProjModeRequestVar='interp_lin';%scalar field (requires interpolation for plot)
@@ -97,14 +100,18 @@
                 ind_var_V=find(strcmp(r.VName,ListVar));%check previous listing of variable r.VName
                 if isempty(ind_var_U)
-                    ListVar=[ListVar r.UName]; % append the variable in the list if not previously listed
+                    ListVar=[ListVar {r.UName}]; % append the variable in the list if not previously listed
                     Role=[Role {'vector_x'}];
                     ProjModeRequest=[ProjModeRequest {ProjModeRequestVar}];
+                    ListInputField=[ListInputField InputField(ilist)];
+                    %ListOperator=[ListOperator {[r.Operator '_U']}];
                 else
                     checkU=1;
                 end
                 if isempty(ind_var_V)
-                    ListVar=[ListVar r.VName];% append the variable in the list if not previously listed
+                    ListVar=[ListVar {r.VName}];% append the variable in the list if not previously listed
                     Role=[Role {'vector_y'}];
                     ProjModeRequest=[ProjModeRequest {ProjModeRequestVar}];
+                    ListInputField=[ListInputField {''}];
+                    %ListOperator=[ListOperator {[r.Operator '_V']}];
                 else
                     checkV=1;
@@ -128,35 +135,45 @@
             end
         end
-        for ivar=1:numel(ListVar)
-            Field.VarAttribute{ivar+2}.Role=Role{ivar};
+        NormName='';
+        UName='';
+        VName='';
+        for ilist=1:numel(ListVar)
+            Field.VarAttribute{ilist+2}.Role=Role{ilist};
+            Field.VarAttribute{ilist+2}.ProjModeRequest=ProjModeRequest{ilist};
             if isfield(ParamIn,'FieldName')
-                Field.VarAttribute{ivar+2}.FieldName=ParamIn.FieldName;
-            end
-            Field.VarAttribute{ivar+2}.ProjModeRequest=ProjModeRequest{ivar};
-        end
-        if strcmp(Operator,'norm')
-             NormName='norm';
-            if ~isempty(strcmp(ListVar,'norm'))
-                NormName='norm_1';
-            end
-            Field.ListVarName=[Field.ListVarName {NormName}];
-            ilist=numel(Field.ListVarName);
-            Field.VarDimName{ilist}=Field.VarDimName{ind_var_U};
-            Field.VarDimName{ilist}.Role='scalar';
-            Field.(NormName)=Field.(r.UName).*Field.(r.UName)+Field.(r.VName).*Field.(r.VName);
-            Field.(NormName)=sqrt(Field.(NormName));
-            if ~checkU && ~checkV
-                Field.ListVarName([ind_var_U ind_var_V])=[];
-                Field.VarDimName([ind_var_U ind_var_V])=[];
-                Field.VarAttribute([ind_var_U ind_var_V])=[];
-            elseif ~checkU
-                Field.ListVarName(ind_var_U)=[];
-                Field.VarDimName(ind_var_U)=[];
-                Field.VarAttribute(ind_var_U )=[];
-            elseif ~checkV
-                                Field.ListVarName(ind_var_V)=[];
-                Field.VarDimName(ind_var_V)=[];
-                Field.VarAttribute(ind_var_V )=[];
-            end
+                Field.VarAttribute{ilist+2}.FieldName=ListInputField{ilist};
+            end
+            r=regexp(ListInputField{ilist},'(?<Operator>(^vec|^norm))\((?<UName>.+),(?<VName>.+)\)$','names');
+            if ~isempty(r)&& strcmp(r.Operator,'norm')
+                NormName='norm';
+                if ~isempty(find(strcmp(ListVar,'norm')))
+                    NormName='norm_1';
+                end
+                Field.ListVarName=[Field.ListVarName {NormName}];
+                ilistmax=numel(Field.ListVarName);
+                Field.VarDimName{ilistmax}=Field.VarDimName{ilist+2};
+                Field.VarAttribute{ilistmax}.Role='scalar';
+                Field.(NormName)=Field.(r.UName).*Field.(r.UName)+Field.(r.VName).*Field.(r.VName);
+                Field.(NormName)=sqrt(Field.(NormName));
+                UName=r.UName;
+                VName=r.VName;
+            end
+        end
+        if ~isempty(NormName)% remove U and V if norm has been calculated and U and V are not needed as variables
+            ind_var_U=find(strcmp(UName,ListVar));%check previous listing of variable r.UName
+            ind_var_V=find(strcmp(VName,ListVar));%check previous listing of variable r.VName
+             if ~checkU && ~checkV
+                    Field.ListVarName([ind_var_U+2 ind_var_V+2])=[];
+                    Field.VarDimName([ind_var_U+2 ind_var_V+2])=[];
+                    Field.VarAttribute([ind_var_U+2 ind_var_V+2])=[];
+                elseif ~checkU
+                    Field.ListVarName(ind_var_U+2)=[];
+                    Field.VarDimName(ind_var_U+2)=[];
+                    Field.VarAttribute(ind_var_U+2 )=[];
+                elseif ~checkV
+                    Field.ListVarName(ind_var_V+2)=[];
+                    Field.VarDimName(ind_var_V+2)=[];
+                    Field.VarAttribute(ind_var_V+2 )=[];
+             end
         end
     case 'video'
