%**************************************************************************
%This function writes the parameter information to the data file.
%
%Input:
%dat_file, data file for results
%param, structure containing program parameters
%   output_file_dir     %Directory for output files
%   pm_br               %Remnant field in the blocks (T)
%   pm_dim(3)           %Magnet block dimensions for each block in coordinate system tied to block [w_x, w_y, w_z] (m) 
%   pm_num_x_pos        %Number of x positions (ie. upper blocks) in the magic finger array
%   pm_x_dis            %X distance between the centers of the magnet blocks (m)
%   pm_y_dis(1 : pm_num_x_pos)  %Y distance from each magnet block surface to the midplane (m)
%   pm_z_pos            %Z position of the magnet array (m)
%   pm_m_dir_up(1 : pm_num_x_pos)  %Magnetization direction of the upper blocks, Convention: +x = 1, -x = 2, +y = 3, -y = 4
%   pm_m_dir_lo(1 : pm_num_x_pos)  %Magnetization direction of the lower blocks, Convention: +x = 1, -x = 2, +y = 3, -y = 4
%   pm_div_size         %Permanent magnet segmentation size along each axis for equivalent charges (m)
%   field_pos(n, 3)     %Positions where field is calculated, [x(n), y(n), z(n)] coordinates (m)
%   field_int_pos(n, 2) %Positions where field integrals are calculated, [x(n), y(n)] coordinates (m)
%
%Zachary Wolf, 9/14/10

function [] = magic_fingers_dat_param(dat_file, param)

%Write the parameter information to the data file
fid = fopen(dat_file, 'a');
fprintf(fid, '\r\n');
fprintf(fid, 'Simulation Parameters:\r\n');
fprintf(fid, 'Output file directory = %s\r\n', param.output_file_dir);
fprintf(fid, 'Remnant field in blocks = %f T\r\n', param.pm_br);
fprintf(fid, 'Width of blocks in x = %f m\r\n', param.pm_dim(1));
fprintf(fid, 'Width of blocks in y = %f m\r\n', param.pm_dim(2));
fprintf(fid, 'Width of blocks in z = %f m\r\n', param.pm_dim(3));
fprintf(fid, 'Number of x positions in array = %i\r\n', param.pm_num_x_pos);
fprintf(fid, 'X distance between blocks in the magnet array = %f m\r\n', param.pm_x_dis);
fprintf(fid, 'Y distances of block surfaces from the midplane (m):\r\n');
fprintf(fid, '  %7.4f', param.pm_y_dis);
fprintf(fid, '\r\n');
fprintf(fid, 'Z position of the magnet array = %f m\r\n', param.pm_z_pos);
fprintf(fid, 'Magnetization direction of the upper blocks (+x = 1, -x = 2, +y = 3, -y = 4):\r\n');
fprintf(fid, '  %1i', param.pm_m_dir_up);
fprintf(fid, '\r\n');
fprintf(fid, 'Magnetization direction of the lower blocks (+x = 1, -x = 2, +y = 3, -y = 4):\r\n');
fprintf(fid, '  %1i', param.pm_m_dir_lo);
fprintf(fid, '\r\n');
fprintf(fid, 'Magnet division size for equivalent charges = %f m\r\n', param.pm_div_size);
fclose(fid);

%Done
end
