%**************************************************************************
%This function writes field harmonic information to the data file.
%
%Input:
%dat_file, data file for results
%al_n, skew multipole field strength at the reference radius (Tm)
%bl_n, normal multipole field strength at the reference radius (Tm)
%r0, reference radius (m)
%
%Zachary Wolf
%10/5/10

function [] = magic_fingers_dat_har_intbxydz(dat_file, al_n, bl_n, r0)
  
%Check
if length(al_n) ~= length(bl_n)
    return;
end
if length(bl_n) == 1
    return;
end

%Write the results to the data file
fid = fopen(dat_file, 'a');
fprintf(fid, '\r\n');
fprintf(fid, 'Multipole Field Coefficients:\r\n');
fprintf(fid, 'int_bx_dz(x) = Sum[aln (x/r0)^(n-1)]\r\n');
fprintf(fid, 'int_by_dz(x) = Sum[bln (x/r0)^(n-1)]\r\n');
fprintf(fid, 'r0 = %f m\r\n', r0);
fprintf(fid, '   n          aln          bln    \r\n');
fprintf(fid, '             (Tm)         (Tm)    \r\n');
fprintf(fid, '--------  -----------  -----------\r\n');
for ii = 1 : length(al_n)
    fprintf(fid, '%4i      %11.3e  %11.3e\r\n', ii, al_n(ii), bl_n(ii));
end
fclose(fid);

%Done
end