function SP=structure_copy(DATA,fields_no_copy,ii_fill_empty)
%
% Call SP=structure_copy(DATA,fields_no_copy,ii_fill_empty);
%
% Copies one structure to another except for fields listed in fields_no_copy.
% For ii_fill_empty=1, fields_no_copy are set to be empty in the structure,
% for ii_fill_empty=0, fields_no_copy are completely ignored;
%
%
% 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.
if nargin<2, fields_no_copy=[]; end
if nargin<3, ii_fill_empty=1; end
%
loaded_fields=fieldnames(DATA);
nnc=length(fields_no_copy);
ii_ok=0;
for j=1:length(loaded_fields),
    iicopy=1;
	if any(strcmp(loaded_fields{j},fields_no_copy)), iicopy=0; end
    if iicopy,
		expr=['SP.',loaded_fields{j},'=DATA.',loaded_fields{j},';']; eval(expr); iiok=1;
    elseif ii_fill_empty,
		expr=['SP.',loaded_fields{j},'=[];']; eval(expr); ii_ok=1;
    end
end
%
if ~ii_ok, SP=struct([]); end
