%**************************************************************************
%This function initializes the data file.
%
%Input:
%dat_file, data file for results
%param, parameter structure
%header, measurement file header
%
%Zachary Wolf, 1/6/08

function [] = fid_dat_init(dat_file, param, header)

%Open the data file
fid = fopen(dat_file, 'w');

%Get time and date information
%c = [y, m, d, h, mi, s]
c = fix(clock);

%Write a header to the data file
fprintf(fid, 'SLAC Magnetic Measurements\r\n');
fprintf(fid, 'Date: %02i-%02i-%4i\r\n', c(2), c(3), c(1));
fprintf(fid, 'Time: %02i:%02i:%02i\r\n', c(4), c(5), c(6));

%Message
fprintf(fid, '\r\n');
fprintf(fid, 'Fiducialization Calculations\r\n');
fprintf(fid, '----------------------------\r\n');

%Write the program parameters
fprintf(fid, '\r\n');
fprintf(fid, 'Program Parameters:\r\n');
fprintf(fid, 'Input zscan file = %s\r\n', param.input_zscan_file);
fprintf(fid, 'Output file directory = %s\r\n', param.output_file_dir);

%Write the measurement file header
%fprintf(fid, '\r\n');
%fprintf(fid, 'Z Scan File Header:\r\n');
%[r, c] = size(header);
%for ii = 1:c
%    if length(header{ii}) > 0
%        fprintf(fid, '%s\r\n', header{ii});
%    end
%end

%Close the data file
fclose(fid);

%Done
