function SP=structure_copy2(SP,DATA,fields_no_copy)
%
% Call SP=structure_copy2(SP,DATA,fields_no_copy);
%
% Copies structure fields from DATA to SP (like structure_copy, but also keeps any field names SP already had).
%
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
loaded_fields=fieldnames(DATA);
nnc=length(fields_no_copy);
for j=1:length(loaded_fields),
    iicopy=1;
    for jnc=1:nnc,
    	if strcmp(loaded_fields{j},fields_no_copy{jnc}), iicopy=0; break; end
    end
    if iicopy,
% This didn't work for no good reason...  Instead, call structure_copy2 on each field that is a
% structure.
%         str=['ii_struct_SP=isstruct(SP.',loaded_fields{j},');'], eval(str);
%         str=['ii_struct_DATA=isstruct(DATA.',loaded_fields{j},');'], eval(str);
%         if ii_struct_SP & ii_struct_DATA,
%             str=['SP.',loaded_fields{j},'=structure_copy2(SP.',loaded_fields{j},',DATA.',loaded_fields{j},',fields_no_copy);'],
%             eval(str);
%         else
		expr=['SP.',loaded_fields{j},'=DATA.',loaded_fields{j},';']; eval(expr);
%         end
    end
end
