disp('prt_HiWinGS_2013_flux_10');
fclose all;
clear jazz;

f = fullfile(da_path,[jdollars,'_flux_10_',datasetv,'_',dcname,'.txt']);
flist = fopen(f,'w');

npz = length(jdy);
jazz(1,1:npz) = jdy';                   % date
jazz(2,1:npz) = ushp';                  % uship scs
jazz(3,1:npz) = u_best';                % u true
jazz(4,1:npz) = dir_best';              % true dir
jazz(5,1:npz) = urel_best';             % u rel
jazz(6,1:npz) = reldir_best';           % rel dir
jazz(7,1:npz) = head';                  % ship heading
jazz(8,1:npz) = ts_best';               % sst
jazz(9,1:npz) = ta_best';               % T
jazz(10,1:npz) = qs_best';              % qs
jazz(11,1:npz) = qa_best';              % qa
jazz(12,1:npz) = hsc';                  % hs covariance, psd
jazz(13,1:npz) = hsib';                 % hs ID, psd
jazz(14,1:npz) = hsbb';                 % hs bulk
jazz(15,1:npz) = hlc_bl';               % hl covariance from licor
jazz(16,1:npz) = hlib_lic';             % hl ID
jazz(17,1:npz) = hlbb';                 % hl bulk
jazz(18,1:npz) = -(rhoair.*wuj)';       % stress streamwise covariance
jazz(19,1:npz) = -(rhoair.*wvj)';       %   "     xstream
jazz(20,1:npz) = (rhoair.*usib.^2)';    % stress by ID
jazz(21,1:npz) = taubb';                % stress bulk
jazz(22,1:npz) = rs_best';              % solar flux
jazz(23,1:npz) = rl_best';              % IR flux
jazz(24,1:npz) = rain_best';            % rain rate
jazz(25,1:npz) = jplume';               % ship plume contam index
jazz(26,1:npz) = tiltx';                % tilt angle
jazz(27,1:npz) = jmanuv';               % maneuver index
jazz(28,1:npz) = ct';                   % ct
jazz(29,1:npz) = cql';                  % cq from Licor
jazz(30,1:npz) = cu';                   % cu
jazz(31,1:npz) = cw';                   % cw
jazz(32,1:npz) = HRF';                  % Rain heat flux
jazz(33,1:npz) = hl_webb';              % Hl webb flux
jazz(34,1:npz) = Lat';                  % lat
jazz(35,1:npz) = Lon';                  % lon
jazz(36,1:npz) = zu_etl';               % zu
jazz(37,1:npz) = zt_etl';               % zt
jazz(38,1:npz) = zq_etl';               % zq
jazz(39,1:npz) = ushp';                 % uship scs
jazz(40,1:npz) = U_scs';                % u true scs
jazz(41,1:npz) = dir_scs';              % true dir scs
jazz(42,1:npz) = x(:,101)';             % ship course scs
jazz(43,1:npz) = tsg';                  % Ts scs
jazz(44,1:npz) = ta_im';                % T scs
jazz(45,1:npz) = qs_tsg';               % qs scs
jazz(46,1:npz) = qa_im';                % qa scs
jazz(47,1:npz) = rs_im';                % solar flux  IMET
jazz(48,1:npz) = rl_im';                % IR flux IMET
jazz(49,1:npz) = jdy'*NaN ;             % <w'c'> Licor - NOT COMPUTED
jazz(50,1:npz) = q_lic';                % Specific Humidity from Licor (g/kg)
jazz(51,1:npz) = sgq_lic';              % Stv of Specific Humidity from Licor (g/kg)
jazz(52,1:npz) = co2_lic';              % CO2 concentration from Licor (umol/mol)
jazz(53,1:npz) = sgco2_lic;             % Stv of CO2 concentration from Licor (umol/mol)
jazz(54,1:npz) = P_best';               % atmospheric pressure (mbar)
jazz(55,1:npz) = Uearth';               % Wind speed (m/s) relative to earth
jazz(56,1:npz) = direarth';             % Wind direction (deg) from relative to earth
jazz(57,1:npz) = rlcler';               % Longwave downwelling clear sky model (W/m2)
jazz(58,1:npz) = Rscl';                 % Shortwave solar radiance clear sky model (W/m2)
jazz(59,1:npz) = hsc_uh';               % flux results for UH sonic, as above
jazz(60,1:npz) = hsib_uh';              % ...
jazz(61,1:npz) = -(rhoair.*wu_uh)';
jazz(62,1:npz) = -(rhoair.*wv_uh)';
jazz(63,1:npz) = (rhoair.*usib_uh.^2)';
jazz(64,1:npz) = tilt_uh';
jazz(65,1:npz) = ct_uh';
jazz(66,1:npz) = cu_uh';
jazz(67,1:npz) = cw_uh';
jazz(68,1:npz) = u10n';                 % neutral 10 m wind speed
jazz(69,1:npz) = usr_psd';              % filtered ustar, covariance, psd sonic
jazz(70,1:npz) = usr_uh';               % filtered ustar, covariance, uh sonic
jazz(71,1:npz) = usr_id_psd';           % filtered ustar, id, psd sonic
jazz(72,1:npz) = usr_id_uh';            % filtered ustar, td, uh sonic
jazz(73,1:npz) = cd10n_id_psd';         % filtered Cd10N, id, psd sonic
jazz(74,1:npz) = cd10n_id_uh';          % filtered Cd10N, id, uh sonic

% vectorized print, 74 columns
% prepare format string for numeric data
fmtStr = '';
fmtStr = strcat('\r\n', fmtStr);
for i = 1:74
    fmtStr = strcat('%12.6f ', fmtStr);
end
fprintf(flist,fmtStr,jazz);
fclose('all');
disp(['File written as ' f]);

flux10 = jazz';
f = fullfile(da_path,[jdollars,'_flux_10_',datasetv,'_',dcname,'.mat']);
save(f, 'flux10');
