% prt_flux_5
% Saves 5-min flux data to a file.
disp(['prt_flux_5_', cruise]);

fclose('all');
clear jazz;

f=[way_proc_data_flux cruise '_PSD_flux_5min_' sprintf('%04i_%02i_%02i_%03i',Vdate(1),Vdate(2),Vdate(3),ddd)  '.txt'];
flist=fopen(f,'w');

jazz(1,1:np)=jad5;      %Decimal julian day at beginning of line
jazz(2,1:np)=s1;        %etl true wind speed at 18.8 m ht, m/s
jazz(3,1:np)=dir1;      %etl true wind direction, deg
jazz(4,1:np)=ts;        %etl seasnake T, C
jazz(5,1:np)=ts_tsg;    %ship theromsalinograph T, C  bow
jazz(6,1:np)=sal_tsg;   %ship theromsalinograph salinity, psu  bow
jazz(7,1:np)=ta;        %etl air T at 18 m, C
jazz(8,1:np)=qs;        %etl air specific humidity at sea surface, g/kg
jazz(9,1:np)=qa;        %etl air specific humidity at 18 m, g/kg
jazz(10,1:np)=psp;      %etl solar flux, w/m^2
jazz(11,1:np)=pir;      %etl IR flux, w/m^2
jazz(12,1:np)=org;      %etl optical raingage precip rate, mm/hr
jazz(13,1:np)=shp_spd;  %ship sog from gps, m/s
jazz(14,1:np)=shp_hed;  %ship heading from gyrocompass, deg
jazz(15,1:np)=relsp;    %rel wind speed, m/s
jazz(16,1:np)=reldir;   %rel wind direction, deg
jazz(17,1:np)=lat;      %decimal latitude, deg
jazz(18,1:np)=lon;      %decimal longtude, deg
jazz(19,1:np)=zt;       %Depth of SST sensor used in heat flux calc, m
jazz(20,1:np)=sig_sp;   %standard deviation of ship speed, m/s
jazz(21,1:np)=taub;     %wind stress, coare 3.0, N/m^2
jazz(22,1:np)=hsb;      %sensible heat flux, coare 3.0, w/m^2
jazz(23,1:np)=hlb;      %latent heat flux, coare 3.0, w/m^2
jazz(24,1:np)=rf;       %rain heat flux, w/m^2
jazz(25,1:np)=ta_im;    %IMET air temp, C (21 m)
jazz(26,1:np)=qa_im;    %IMET air specific humidity, g/kg (21 m)
jazz(27,1:np)=s_shp;    %IMET true wind speed, m/s (21 m)
jazz(28,1:np)=dir_shp;  %IMET true wind direction, deg (21 m)
jazz(29,1:np)=psp_im;   %IMET solar flux, w/m^2
jazz(30,1:np)=pir_im;   %IMET IR flux, w/m^2
jazz(31,1:np)=pressm;   %BP, mb
jazz(32,1:np)=rh_etl;   %RH (%)

%vectorized print
%                 1        2       3      4       5       6       7       8       9      10      11       12     13       14      15     16        17     18       19      20      21       22      23      24       25      26      27      28      29      30
fprintf(flist,'%11.5f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %12.4f\t %12.4f\t %9.2f\t %9.2f\t %8.3f\t %9.2f\t %9.2f\t %9.2f\t  %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t %9.2f\t  %9.2f\t \r\n',jazz);
fclose('all');
	
