function makepco2(infile, outfile)

% Brian Schlining

n       = ncnames(infile);
outfile = netcdf(outfile, 'clobber');

t  = infile{'time_d'}(:);
var_t = infile{'time_d'};
p  = infile{'pco2'}(:);
var_p = infile{'pco2'};

globalAtt = att(infile);
copy(globalAtt, outfile);

dimensions = dim(infile);
outfile('time') = 0;
copy(infile{'latitude'}, outfile, 1, 1, 1)  % Copy the dimension exactly
copy(infile{'longitude'}, outfile, 1, 1, 1) % Copy the dimension exactly

att_t = att(var_t);
outfile{'time'} = ncfloat('time');
for i = 1:length(att_t)
   copy(outfile{'time'}, att_t(i));   % Copy the attributes of time
end

att_p = att(var_p);
outfile{'pco2'} = ncfloat('time', 'latitude', 'longitude');
for i = 1:length(att_p)
   copy(outfile{'pco2'}, att_t(i));   % Copy the attributes of time
end
