%**************************************************************************
% CLUSTER project: Store jav and divB              Autor: Christian Maszl * 
% Unit System = [SI]                  Mail: e0025754@student.tuwien.ac.at *
%**************************************************************************
%
% This subroutine store the computed data to the harddisk. 
%
% Filename format for jav: 
% [yymmdd]0000[type].jav..[coordsys].[timeformat].[igmmat]
% Example: 0203040000fn.jav.gse.hr.igmmat
% 
% Format of the data in the file: [time jav]
%
% Filename format for <divB>: 
% [yymmdd]0000[type].divB.[coordsys].[timeformat].[igmmat]
% Example: 0203040000fn.divB.gse.hr.igmmat
%
% Format of the data in the file: [time divB]
%
% Filename format for B: 
% [yymmdd]0000[type].B1-4.[coordsys].[timeformat].[igmmat]
% Example: 0203040000fn.B1-4.gse.hr.igmmat
%
% Format of the data in the file: [time B1 B2 B3 B4]

% Take a name of the datapackage and replace the satellite number with
% jav (current density)
     satz = strrep(myfilelist{lauf,1},'.01','.jav.');
% Check for datatype and fix the extension
if (size(datatype,2)==4)
     filename = [outputspath satz 'gse.hr.igmmat'];
else
     filename = [outputspath satz 'gse.hr.igmasc'];
end
% Create temporary carrier for output data and add time
     jav=[T jav];
% Save data (binary=5x faster) to disk
     save(filename,'jav',datatype); 
% Take a name of the datapackage and replace the satellite number with
% divB
filename=strrep(filename,'.jav.','.divB.');
% Create temporary carrier for output data and add time
     divB=[T divB];
% Save data (binary=5x faster) to disk
     save(filename,'divB',datatype);
% Save data (binary=5x faster) to disk
filename=strrep(filename,'.divB.','.B1-4.');
     B=[T B1 B2 B3 B4];
     save(filename,'B',datatype);
% Clear dispensable variables
     clear filename satz;
