% ------------------------------------------------------------------------------
% Process decoded data into Argo dedicated structures.
%
% SYNTAX :
%  [o_tabProfiles, ...
%    o_tabTrajNMeas, o_tabTrajNCycle, ...
%    o_tabNcTechIndex, o_tabNcTechVal, o_tabTechNMeas] = ...
%    process_decoded_data( ...
%    a_decodedDataTab, a_refDay, a_decoderId, ...
%    a_tabProfiles, ...
%    a_tabTrajNMeas, a_tabTrajNCycle, ...
%    a_tabNcTechIndex, a_tabNcTechVal, a_tabTechNMeas)
%
% INPUT PARAMETERS :
%   a_decodedDataTab : decoded data
%   a_refDay         : reference day
%   a_decoderId      : float decoder Id
%   a_tabProfiles    : input decoded profiles
%   a_tabTrajNMeas   : input decoded trajectory N_MEASUREMENT data
%   a_tabTrajNCycle  : input decoded trajectory N_CYCLE data
%   a_tabNcTechIndex : input decoded technical index information
%   a_tabNcTechVal   : input decoded technical data
%   a_tabTechNMeas   : input decoded technical PARAM data
%
% OUTPUT PARAMETERS :
%   o_tabProfiles    : output decoded profiles
%   o_tabTrajNMeas   : output decoded trajectory N_MEASUREMENT data
%   o_tabTrajNCycle  : output decoded trajectory N_CYCLE data
%   o_tabNcTechIndex : output decoded technical index information
%   o_tabNcTechVal   : output decoded technical data
%   o_tabTechNMeas   : output decoded technical PARAM data
%
% EXAMPLES :
%
% SEE ALSO :
% AUTHORS  : Jean-Philippe Rannou (Altran)(jean-philippe.rannou@altran.com)
% ------------------------------------------------------------------------------
% RELEASES :
%   12/17/2018 - RNU - creation
% ------------------------------------------------------------------------------
function [o_tabProfiles, ...
   o_tabTrajNMeas, o_tabTrajNCycle, ...
   o_tabNcTechIndex, o_tabNcTechVal, o_tabTechNMeas] = ...
   process_decoded_data( ...
   a_decodedDataTab, a_refDay, a_decoderId, ...
   a_tabProfiles, ...
   a_tabTrajNMeas, a_tabTrajNCycle, ...
   a_tabNcTechIndex, a_tabNcTechVal, a_tabTechNMeas)

% output parameters initialization
o_tabProfiles = a_tabProfiles;
o_tabTrajNMeas = a_tabTrajNMeas;
o_tabTrajNCycle = a_tabTrajNCycle;
o_tabNcTechIndex = a_tabNcTechIndex;
o_tabNcTechVal = a_tabNcTechVal;
o_tabTechNMeas = a_tabTechNMeas;

% current float WMO number
global g_decArgo_floatNum;

% current cycle number
global g_decArgo_cycleNum;

% output CSV file Id
global g_decArgo_outputCsvFileId;

% default values
global g_decArgo_presDef;
global g_decArgo_tempDef;
global g_decArgo_c1C2PhaseDoxyDef;
global g_decArgo_tempDoxyDef;
global g_decArgo_doxyDef;

% output NetCDF technical parameter index information
global g_decArgo_outputNcParamIndex;

% output NetCDF technical parameter values
global g_decArgo_outputNcParamValue;

% array to store GPS data
global g_decArgo_gpsData;

% array to store Iridium mail contents
global g_decArgo_iridiumMailData;

% generate nc flag
global g_decArgo_generateNcFlag;

% number of the first deep cycle
global g_decArgo_firstDeepCycleNumber;
g_decArgo_firstDeepCycleNumber = 1;

% offset between float days and julian days
global g_decArgo_julD2FloatDayOffset;

% RT processing flag
global g_decArgo_realtimeFlag;

% report information structure
global g_decArgo_reportStruct;

% clock offset management
global g_decArgo_clockOffset;

% from
% - decId 223 for Arvor
% - decId 221 for Arvor Deep
% - decId 225 for Provor
% configuration parameters are not transmitted each cycle
% consequently we must update the configuration of the second deep cycle with
% initial parameters, this should be done once (except if alterneated profil or
% auto-increment flag are set)
global  g_decArgo_doneOnceFlag;


% no data to process
if (isempty(a_decodedDataTab))
   return
end

g_decArgo_generateNcFlag = 1;

% set information on current cycle
g_decArgo_cycleNum = unique([a_decodedDataTab.cyNum]);
deepCycleFlag =  unique([a_decodedDataTab.deep]);
if (~any([a_decodedDataTab.reset] == 1))
   resetDetectedFlag = 0;
else
   resetDetectedFlag = 1;
end
julD2FloatDayOffset = setdiff(unique([a_decodedDataTab.julD2FloatDayOffset]), -1);
if (~isempty(julD2FloatDayOffset))
   g_decArgo_julD2FloatDayOffset = julD2FloatDayOffset;
end
iceDelayedCycleFlag = unique([a_decodedDataTab.iceDelayed]);

if (g_decArgo_realtimeFlag == 1)
   % update the reports structure cycle list
   g_decArgo_reportStruct.cycleList = [g_decArgo_reportStruct.cycleList g_decArgo_cycleNum];
end

% print SBD file description for output CSV file
if (~isempty(g_decArgo_outputCsvFileId))
   
   fileNameList = unique({a_decodedDataTab.fileName}, 'stable');
   for idFile = 1:length(fileNameList)
      idForFile = find(strcmp({a_decodedDataTab.fileName}, fileNameList{idFile}));
      packTypeList = [a_decodedDataTab(idForFile).packType];
      cyInfoStr = '';
      uPackTypeList = unique(packTypeList);
      for idP = 1:length(uPackTypeList)
         cyInfoStr = [cyInfoStr sprintf('#%d ', uPackTypeList(idP))];
         if (length(find(packTypeList == uPackTypeList(idP))) > 1)
            cyInfoStr = [cyInfoStr sprintf('(%d) ', length(find(packTypeList == uPackTypeList(idP))))];
         end
      end
      fprintf(g_decArgo_outputCsvFileId, '%d; -; info SBD file; File #%03d:   %s; Size: %d bytes; Nb Packets: %d; Cy %d : %s\n', ...
         g_decArgo_floatNum, ...
         idFile, fileNameList{idFile}, 100*length(idForFile), length(idForFile), ...
         g_decArgo_cycleNum, cyInfoStr(1:end-1));
   end
end

fprintf('DEC_INFO: Float #%d Cycle #%d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum);

% process decoded data

tabBuffProfiles = [];
tabBuffTrajNMeas = [];
tabBuffTrajNCycle = [];
tabBuffNcTechIndex = [];
tabBuffNcTechVal = [];
tabBuffTechNMeas = [];

switch (a_decoderId)
   
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   case {212} % Arvor-ARN-Ice Iridium 5.45
      
      % get decoded data
      [tabTech1, tabTech2, ...
         dataCTD, ~, ...
         ~, ~, ...
         evAct, pumpAct, ...
         floatParam1, floatParam2] = ...
         get_decoded_data(a_decodedDataTab, a_decoderId);
      
      % assign the current configuration to the current deep cycle
      if ((g_decArgo_cycleNum > 0) && ((deepCycleFlag == 1) || (resetDetectedFlag == 1)))
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
      end
      
      % update float configuration for the next cycles
      if ~(isempty(floatParam1) && isempty(floatParam2))
         update_float_config_ir_sbd_delayed([{floatParam1} {floatParam2}], g_decArgo_cycleNum, a_decoderId);
      end
      if (g_decArgo_cycleNum == -1)
         % only consider parameter packets for cycle number -1
         return
      end
      
      % assign the configuration received during the prelude to this cycle
      if (g_decArgo_cycleNum == 0)
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
      end
      
      % store GPS data and compute JAMSTEC QC for the GPS locations of the
      % current cycle
      store_gps_data_ir_sbd(tabTech1, g_decArgo_cycleNum, a_decoderId);
      
      % convert counts to physical values
      if (~isempty(dataCTD))
         [dataCTD(:, 33:47)] = sensor_2_value_for_pressure_202_210_to_214_217_222_to_225(dataCTD(:, 33:47));
         [dataCTD(:, 48:62)] = sensor_2_value_for_temp_204_to_214_217_219_220_222_to_225(dataCTD(:, 48:62));
         [dataCTD(:, 63:77)] = sensor_2_value_for_salinity_210_to_214_217_220_222_to_225(dataCTD(:, 63:77));
      end
      
      % create drift data set
      [parkDate, parkTransDate, ...
         parkPres, parkTemp, parkSal] = ...
         create_prv_drift_212_222(dataCTD, g_decArgo_julD2FloatDayOffset);
      
      % create descending and ascending profiles
      [descProfDate, descProfPres, descProfTemp, descProfSal, ...
         ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
         nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
         inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal] = ...
         create_prv_profile_212_222(dataCTD, deepCycleFlag, g_decArgo_julD2FloatDayOffset);
      
      % compute the main dates of the cycle
      [cycleStartDate, ...
         descentToParkStartDate, ...
         firstStabDate, firstStabPres, ...
         descentToParkEndDate, ...
         descentToProfStartDate, ...
         descentToProfEndDate, ...
         ascentStartDate, ...
         ascentEndDate, ...
         transStartDate, ...
         gpsDate, ...
         lastResetDate, ...
         firstGroundingDate, firstGroundingPres, ...
         secondGroundingDate, secondGroundingPres, ...
         eolStartDate, ...
         firstEmergencyAscentDate, firstEmergencyAscentPres, ...
         iceDetected] = ...
         compute_prv_dates_212_214_217(tabTech1, tabTech2, deepCycleFlag, iceDelayedCycleFlag, a_refDay);
      
      if (~isempty(g_decArgo_outputCsvFileId))
         
         % output CSV file
         
         % print float technical messages in CSV file
         print_tech_data_in_csv_file_212(tabTech1, tabTech2, deepCycleFlag);
         
         % print dated data in CSV file
         print_dates_in_csv_file_212_214_217( ...
            cycleStartDate, ...
            descentToParkStartDate, ...
            firstStabDate, firstStabPres, ...
            descentToParkEndDate, ...
            descentToProfStartDate, ...
            descentToProfEndDate, ...
            ascentStartDate, ...
            ascentEndDate, ...
            transStartDate, ...
            gpsDate, ...
            firstGroundingDate, firstGroundingPres, ...
            secondGroundingDate, secondGroundingPres, ...
            eolStartDate, ...
            firstEmergencyAscentDate, firstEmergencyAscentPres, ...
            descProfDate, descProfPres, ...
            parkDate, parkPres, ...
            ascProfDate, ascProfPres, ...
            nearSurfDate, nearSurfPres, ...
            inAirDate, inAirPres, ...
            evAct, pumpAct);
         
         % print descending profile in CSV file
         print_descending_profile_in_csv_file_204_205_210_to_212( ...
            descProfDate, descProfPres, descProfTemp, descProfSal);
         
         % print drift measurements in CSV file
         print_drift_measurements_in_csv_file_204_205_210_to_212( ...
            parkDate, parkTransDate, ...
            parkPres, parkTemp, parkSal);
         
         % print ascending profile in CSV file
         print_ascending_profile_in_csv_file_204_205_210_to_212( ...
            ascProfDate, ascProfPres, ascProfTemp, ascProfSal);
         
         % print "near surface" and "in air" measurements in CSV file
         print_in_air_meas_in_csv_file_210_to_217( ...
            nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
            [], [], [], [], ...
            inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
            [], [], [], []);
         
         % print EV and pump data in CSV file
         print_hydraulic_data_in_csv_file_212_214_217_218(evAct, pumpAct);
         
         % print float parameters in CSV file
         print_float_prog_param_in_csv_file_212_214_217(floatParam1, floatParam2);
         
      else
         
         % output NetCDF files
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % PROF NetCDF file
         
         % process profile data for PROF NetCDF file
         tabProfiles = [];
         if (~isempty(dataCTD))
            
            [tabProfiles] = process_profiles_212( ...
               descProfDate, descProfPres, descProfTemp, descProfSal, ...
               ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
               g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
               descentToParkStartDate, ascentEndDate, transStartDate, ...
               tabTech2, iceDetected, a_decoderId);
            
            % add the vertical sampling scheme from configuration
            % information
            [tabProfiles] = add_vertical_sampling_scheme_ir_sbd(tabProfiles, a_decoderId);
            
            print = 0;
            if (print == 1)
               if (~isempty(tabProfiles))
                  fprintf('DEC_INFO: Float #%d Cycle #%d: %d profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum, length(tabProfiles));
                  for idP = 1:length(tabProfiles)
                     prof = tabProfiles(idP);
                     paramList = prof.paramList;
                     paramList = sprintf('%s ', paramList.name);
                     profLength = size(prof.data, 1);
                     fprintf('   ->%2d: dir=%c length=%d param=(%s)\n', ...
                        idP, prof.direction, ...
                        profLength, paramList(1:end-1));
                  end
               else
                  fprintf('DEC_INFO: Float #%d Cycle #%d: No profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum);
               end
            end
            
            tabBuffProfiles = [tabBuffProfiles tabProfiles];
         end
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TRAJ NetCDF file
         
         % process trajectory data for TRAJ NetCDF file
         [tabTrajNMeas, tabTrajNCycle, tabTechNMeas] = process_trajectory_data_212( ...
            g_decArgo_cycleNum, deepCycleFlag, ...
            g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
            cycleStartDate, ...
            descentToParkStartDate, firstStabDate, firstStabPres, descentToParkEndDate, ...
            descentToProfStartDate, descentToProfEndDate, ...
            ascentStartDate, ascentEndDate, ...
            transStartDate, ...
            firstGroundingDate, firstGroundingPres, ...
            secondGroundingDate, secondGroundingPres, ...
            tabTech1, tabTech2, ...
            tabProfiles, ...
            parkDate, parkTransDate, parkPres, parkTemp, parkSal, ...
            nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
            inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
            evAct, pumpAct, iceDetected);
         
         % sort trajectory data structures according to the predefined
         % measurement code order
         [tabTrajNMeas] = sort_trajectory_data(tabTrajNMeas, a_decoderId);
         
         tabBuffTrajNMeas = [tabBuffTrajNMeas tabTrajNMeas];
         tabBuffTrajNCycle = [tabBuffTrajNCycle tabTrajNCycle];
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TECH NetCDF file
         
         % store information on received Iridium packet types
         if (deepCycleFlag == 1)
            store_received_packet_type_info_for_nc(a_decoderId);
         end
         
         % store NetCDF technical data
         store_tech1_data_for_nc_210_to_212(tabTech1, deepCycleFlag);
         store_tech2_data_for_nc_212_214_217_222_223_225(tabTech2, deepCycleFlag, iceDetected);
         
         % store additional technical decoding information (for TECH_AUX
         % file)
         store_misc_tech_data_for_nc_212_214_216_to_218_222_to_225(a_decodedDataTab, a_decoderId);

         tabBuffNcTechIndex = [tabBuffNcTechIndex; g_decArgo_outputNcParamIndex];
         tabBuffNcTechVal = [tabBuffNcTechVal g_decArgo_outputNcParamValue];
         tabBuffTechNMeas = [tabBuffTechNMeas tabTechNMeas];
         
         g_decArgo_outputNcParamIndex = [];
         g_decArgo_outputNcParamValue = [];
         
      end
      
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   case {214, 217}
      % Provor-ARN-DO-Ice Iridium 5.75
      % Arvor-ARN-DO-Ice Iridium 5.46
      
      % get decoded data
      [tabTech1, tabTech2, ...
         dataCTD, dataCTDO, ...
         ~, ~, ...
         evAct, pumpAct, ...
         floatParam1, floatParam2] = ...
         get_decoded_data(a_decodedDataTab, a_decoderId);
      
      % assign the current configuration to the current deep cycle
      if ((g_decArgo_cycleNum > 0) && ((deepCycleFlag == 1) || (resetDetectedFlag == 1)))
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
      end
      
      % update float configuration for the next cycles
      if ~(isempty(floatParam1) && isempty(floatParam2))
         update_float_config_ir_sbd_delayed([{floatParam1} {floatParam2}], g_decArgo_cycleNum, a_decoderId);
      end
      if (g_decArgo_cycleNum == -1)
         % only consider parameter packets for cycle number -1
         return
      end
      
      % assign the configuration received during the prelude to this cycle
      if (g_decArgo_cycleNum == 0)
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
      end
      
      % store GPS data and compute JAMSTEC QC for the GPS locations of the
      % current cycle
      store_gps_data_ir_sbd(tabTech1, g_decArgo_cycleNum, a_decoderId);
      
      % convert counts to physical values
      if (~isempty(dataCTD))
         [dataCTD(:, 33:47)] = sensor_2_value_for_pressure_202_210_to_214_217_222_to_225(dataCTD(:, 33:47));
         [dataCTD(:, 48:62)] = sensor_2_value_for_temp_204_to_214_217_219_220_222_to_225(dataCTD(:, 48:62));
         [dataCTD(:, 63:77)] = sensor_2_value_for_salinity_210_to_214_217_220_222_to_225(dataCTD(:, 63:77));
      end
      if (~isempty(dataCTDO))
         [dataCTDO(:, 17:23)] = sensor_2_value_for_pressure_202_210_to_214_217_222_to_225(dataCTDO(:, 17:23));
         [dataCTDO(:, 24:30)] = sensor_2_value_for_temp_204_to_214_217_219_220_222_to_225(dataCTDO(:, 24:30));
         [dataCTDO(:, 31:37)] = sensor_2_value_for_salinity_210_to_214_217_220_222_to_225(dataCTDO(:, 31:37));
         [dataCTDO(:, 38:51)] = sensor_2_value_for_C1C2phase_ir_sbd_2xx(dataCTDO(:, 38:51));
         [dataCTDO(:, 52:58)] = sensor_2_value_for_temp_doxy_ir_sbd_2xx(dataCTDO(:, 52:58));
      end
      
      % create drift data set
      [parkDate, parkTransDate, ...
         parkPres, parkTemp, parkSal, ...
         parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy] = ...
         create_prv_drift_214_217_223_225(dataCTD, dataCTDO, g_decArgo_julD2FloatDayOffset);
      
      % create descending and ascending profiles
      [descProfDate, descProfPres, descProfTemp, descProfSal, ...
         descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, ...
         ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
         ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ...
         nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
         nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, ...
         inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
         inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy] = ...
         create_prv_profile_214_217_223_225(dataCTD, dataCTDO, deepCycleFlag, g_decArgo_julD2FloatDayOffset);
      
      % compute DOXY
      descProfDoxy = [];
      parkDoxy = [];
      ascProfDoxy = [];
      nearSurfPpoxDoxy = [];
      inAirPpoxDoxy = [];
      if (~isempty(dataCTDO))
         
         % C1/2PHASE_DOXY -> DOXY using third method: "Stern-Volmer equation"
         [descProfDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, ...
            descProfPres, descProfTemp, descProfSal);
         [parkDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, ...
            parkPres, parkTemp, parkSal);
         [ascProfDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ...
            ascProfPres, ascProfTemp, ascProfSal);
         
         % compute PPOX_DOXY from C1PHASE_DOXY and C2PHASE_DOXY using the Stern-Volmer equation
         [nearSurfPpoxDoxy] = compute_PPOX_DOXY_213_to_218_221_223_225( ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, ...
            g_decArgo_c1C2PhaseDoxyDef, g_decArgo_c1C2PhaseDoxyDef, g_decArgo_tempDoxyDef, ...
            nearSurfPres, nearSurfTemp, ...
            g_decArgo_presDef, g_decArgo_tempDef, ...
            g_decArgo_doxyDef);
         [inAirPpoxDoxy] = compute_PPOX_DOXY_213_to_218_221_223_225( ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, ...
            g_decArgo_c1C2PhaseDoxyDef, g_decArgo_c1C2PhaseDoxyDef, g_decArgo_tempDoxyDef, ...
            inAirPres, inAirTemp, ...
            g_decArgo_presDef, g_decArgo_tempDef, ...
            g_decArgo_doxyDef);
      end
      
      % compute the main dates of the cycle
      [cycleStartDate, ...
         descentToParkStartDate, ...
         firstStabDate, firstStabPres, ...
         descentToParkEndDate, ...
         descentToProfStartDate, ...
         descentToProfEndDate, ...
         ascentStartDate, ...
         ascentEndDate, ...
         transStartDate, ...
         gpsDate, ...
         lastResetDate, ...
         firstGroundingDate, firstGroundingPres, ...
         secondGroundingDate, secondGroundingPres, ...
         eolStartDate, ...
         firstEmergencyAscentDate, firstEmergencyAscentPres, ...
         iceDetected] = ...
         compute_prv_dates_212_214_217(tabTech1, tabTech2, deepCycleFlag, iceDelayedCycleFlag, a_refDay);
      
      if (~isempty(g_decArgo_outputCsvFileId))
         
         % output CSV file
         
         % print float technical messages in CSV file
         print_tech_data_in_csv_file_214_217(tabTech1, tabTech2, deepCycleFlag);
         
         % print dated data in CSV file
         print_dates_in_csv_file_212_214_217( ...
            cycleStartDate, ...
            descentToParkStartDate, ...
            firstStabDate, firstStabPres, ...
            descentToParkEndDate, ...
            descentToProfStartDate, ...
            descentToProfEndDate, ...
            ascentStartDate, ...
            ascentEndDate, ...
            transStartDate, ...
            gpsDate, ...
            firstGroundingDate, firstGroundingPres, ...
            secondGroundingDate, secondGroundingPres, ...
            eolStartDate, ...
            firstEmergencyAscentDate, firstEmergencyAscentPres, ...
            descProfDate, descProfPres, ...
            parkDate, parkPres, ...
            ascProfDate, ascProfPres, ...
            nearSurfDate, nearSurfPres, ...
            inAirDate, inAirPres, ...
            evAct, pumpAct);
         
         % print descending profile in CSV file
         print_desc_profile_in_csv_file_201_to_203_206_to_208_213_to_218( ...
            descProfDate, descProfPres, descProfTemp, descProfSal, ...
            descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, descProfDoxy);
         
         % print drift measurements in CSV file
         print_drift_meas_in_csv_file_201_to_203_206_to_208_213_to_218( ...
            parkDate, parkTransDate, ...
            parkPres, parkTemp, parkSal, ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, parkDoxy);
         
         % print ascending profile in CSV file
         print_asc_profile_in_csv_file_201_to_203_206_to_208_213_to_218( ...
            ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
            ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ascProfDoxy);
         
         % print "near surface" and "in air" measurements in CSV file
         print_in_air_meas_in_csv_file_210_to_217( ...
            nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, nearSurfPpoxDoxy, ...
            inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, inAirPpoxDoxy);
         
         % print EV and pump data in CSV file
         print_hydraulic_data_in_csv_file_212_214_217_218(evAct, pumpAct);
         
         % print float parameters in CSV file
         print_float_prog_param_in_csv_file_212_214_217(floatParam1, floatParam2);
         
      else
         
         % output NetCDF files
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % PROF NetCDF file
         
         % process profile data for PROF NetCDF file
         tabProfiles = [];
         if ~(isempty(descProfPres) && isempty(ascProfPres))
            
            [tabProfiles] = process_profiles_214_217( ...
               descProfDate, descProfPres, descProfTemp, descProfSal, ...
               descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, descProfDoxy, ...
               ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
               ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ascProfDoxy, ...
               g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
               descentToParkStartDate, ascentEndDate, transStartDate, ...
               tabTech2, iceDetected, a_decoderId);
            
            % add the vertical sampling scheme from configuration
            % information
            [tabProfiles] = add_vertical_sampling_scheme_ir_sbd(tabProfiles, a_decoderId);
            
            print = 0;
            if (print == 1)
               if (~isempty(tabProfiles))
                  fprintf('DEC_INFO: Float #%d Cycle #%d: %d profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum, length(tabProfiles));
                  for idP = 1:length(tabProfiles)
                     prof = tabProfiles(idP);
                     paramList = prof.paramList;
                     paramList = sprintf('%s ', paramList.name);
                     profLength = size(prof.data, 1);
                     fprintf('   ->%2d: dir=%c length=%d param=(%s)\n', ...
                        idP, prof.direction, ...
                        profLength, paramList(1:end-1));
                  end
               else
                  fprintf('DEC_INFO: Float #%d Cycle #%d: No profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum);
               end
            end
            
            tabBuffProfiles = [tabBuffProfiles tabProfiles];
         end
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TRAJ NetCDF file
         
         % process trajectory data for TRAJ NetCDF file
         [tabTrajNMeas, tabTrajNCycle, tabTechNMeas] = process_trajectory_data_214_217( ...
            g_decArgo_cycleNum, deepCycleFlag, ...
            g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
            cycleStartDate, ...
            descentToParkStartDate, firstStabDate, firstStabPres, descentToParkEndDate, ...
            descentToProfStartDate, descentToProfEndDate, ...
            ascentStartDate, ascentEndDate, ...
            transStartDate, ...
            firstGroundingDate, firstGroundingPres, ...
            secondGroundingDate, secondGroundingPres, ...
            tabTech1, tabTech2, ...
            tabProfiles, ...
            parkDate, parkTransDate, parkPres, parkTemp, parkSal, ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, parkDoxy, ...
            nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, nearSurfPpoxDoxy, ...
            inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, inAirPpoxDoxy, ...
            evAct, pumpAct, iceDetected, a_decoderId);
         
         % sort trajectory data structures according to the predefined
         % measurement code order
         [tabTrajNMeas] = sort_trajectory_data(tabTrajNMeas, a_decoderId);
         
         tabBuffTrajNMeas = [tabBuffTrajNMeas tabTrajNMeas];
         tabBuffTrajNCycle = [tabBuffTrajNCycle tabTrajNCycle];
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TECH NetCDF file
         
         % store information on received Iridium packet types
         if (deepCycleFlag == 1)
            store_received_packet_type_info_for_nc(a_decoderId);
         end
         
         % store NetCDF technical data
         store_tech1_data_for_nc_213_214_217(tabTech1, deepCycleFlag);
         store_tech2_data_for_nc_212_214_217_222_223_225(tabTech2, deepCycleFlag, iceDetected);
         
         % store additional technical decoding information (for TECH_AUX
         % file)
         store_misc_tech_data_for_nc_212_214_216_to_218_222_to_225(a_decodedDataTab, a_decoderId);
         
         tabBuffNcTechIndex = [tabBuffNcTechIndex; g_decArgo_outputNcParamIndex];
         tabBuffNcTechVal = [tabBuffNcTechVal g_decArgo_outputNcParamValue];
         tabBuffTechNMeas = [tabBuffTechNMeas tabTechNMeas];
         
         g_decArgo_outputNcParamIndex = [];
         g_decArgo_outputNcParamValue = [];
         
      end
      
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   case {216} % Arvor-Deep-Ice Iridium 5.65 (IFREMER version)
      
      % get decoded data
      [tabTech1, tabTech2, ...
         dataCTD, dataCTDO, ...
         ~, ~, ...
         evAct, pumpAct, ...
         floatParam1, ~] = ...
         get_decoded_data(a_decodedDataTab, a_decoderId);
      
      % assign the current configuration to the current deep cycle
      if ((g_decArgo_cycleNum > 0) && ((deepCycleFlag == 1) || (resetDetectedFlag == 1)))
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
      end
      
      % update float configuration for the next cycles
      if (~isempty(floatParam1))
         update_float_config_ir_sbd_delayed(floatParam1, g_decArgo_cycleNum, a_decoderId);
      end
      if (g_decArgo_cycleNum == -1)
         % only consider parameter packets for cycle number -1
         return
      end
      
      % assign the configuration received during the prelude to this cycle
      if (g_decArgo_cycleNum == 0)
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
      end
      
      % store GPS data and compute JAMSTEC QC for the GPS locations of the
      % current cycle
      store_gps_data_ir_sbd(tabTech1, g_decArgo_cycleNum, a_decoderId);
      
      % convert counts to physical values
      if (~isempty(dataCTD))
         [dataCTD(:, 33:47)] = sensor_2_value_for_pressure_201_203_215_216_218_221(dataCTD(:, 33:47));
         [dataCTD(:, 48:62)] = sensor_2_value_for_temperature_201_to_203_215_216_218_221(dataCTD(:, 48:62));
         [dataCTD(:, 63:77)] = sensor_2_value_for_salinity_201_to_203_215_216_218_221(dataCTD(:, 63:77));
      end
      if (~isempty(dataCTDO))
         [dataCTDO(:, 17:23)] = sensor_2_value_for_pressure_201_203_215_216_218_221(dataCTDO(:, 17:23));
         [dataCTDO(:, 24:30)] = sensor_2_value_for_temperature_201_to_203_215_216_218_221(dataCTDO(:, 24:30));
         [dataCTDO(:, 31:37)] = sensor_2_value_for_salinity_201_to_203_215_216_218_221(dataCTDO(:, 31:37));
         [dataCTDO(:, 38:51)] = sensor_2_value_for_C1C2phase_ir_sbd_2xx(dataCTDO(:, 38:51));
         [dataCTDO(:, 52:58)] = sensor_2_value_for_temp_doxy_ir_sbd_2xx(dataCTDO(:, 52:58));
      end
      
      % create drift data set
      [parkDate, parkTransDate, ...
         parkPres, parkTemp, parkSal, ...
         parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy] = ...
         create_prv_drift_201_to_203_215_216_218_221(dataCTD, dataCTDO, 2);
      
      % create descending and ascending profiles
      [descProfDate, descProfPres, descProfTemp, descProfSal, ...
         descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, ...
         ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
         ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ...
         nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
         nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, ...
         inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
         inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy] = ...
         create_prv_profile_215_216_218_221(dataCTD, dataCTDO, 2);
      
      % compute DOXY
      descProfDoxy = [];
      parkDoxy = [];
      ascProfDoxy = [];
      nearSurfPpoxDoxy = [];
      inAirPpoxDoxy = [];
      if (~isempty(dataCTDO))
         
         % C1/2PHASE_DOXY -> DOXY using third method: "Stern-Volmer equation"
         [descProfDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, ...
            descProfPres, descProfTemp, descProfSal);
         [parkDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, ...
            parkPres, parkTemp, parkSal);
         [ascProfDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ...
            ascProfPres, ascProfTemp, ascProfSal);
         
         % compute PPOX_DOXY from C1PHASE_DOXY and C2PHASE_DOXY using the Stern-Volmer equation
         [nearSurfPpoxDoxy] = compute_PPOX_DOXY_213_to_218_221_223_225( ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, ...
            g_decArgo_c1C2PhaseDoxyDef, g_decArgo_c1C2PhaseDoxyDef, g_decArgo_tempDoxyDef, ...
            nearSurfPres, nearSurfTemp, ...
            g_decArgo_presDef, g_decArgo_tempDef, ...
            g_decArgo_doxyDef);
         [inAirPpoxDoxy] = compute_PPOX_DOXY_213_to_218_221_223_225( ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, ...
            g_decArgo_c1C2PhaseDoxyDef, g_decArgo_c1C2PhaseDoxyDef, g_decArgo_tempDoxyDef, ...
            inAirPres, inAirTemp, ...
            g_decArgo_presDef, g_decArgo_tempDef, ...
            g_decArgo_doxyDef);
      end
      
      % compute the main dates of the cycle
      [cycleStartDate, ...
         descentToParkStartDate, ...
         firstStabDate, firstStabPres, ...
         descentToParkEndDate, ...
         descentToProfStartDate, ...
         descentToProfEndDate, ...
         ascentStartDate, ...
         ascentEndDate, ...
         transStartDate, ...
         gpsDate, ...
         eolStartDate, ...
         firstGroundingDate, firstGroundingPres, ...
         secondGroundingDate, secondGroundingPres, ...
         firstEmergencyAscentDate, firstEmergencyAscentPres, ...
         iceDetected] = ...
         compute_prv_dates_216_218(tabTech1, tabTech2, deepCycleFlag, iceDelayedCycleFlag, a_refDay);
      
      if (~isempty(g_decArgo_outputCsvFileId))
         
         % output CSV file
         
         % print float technical messages in CSV file
         print_tech_data_in_csv_file_216(tabTech1, tabTech2, deepCycleFlag);
         
         % print dated data in CSV file
         print_dates_in_csv_file_215_216( ...
            cycleStartDate, ...
            descentToParkStartDate, ...
            firstStabDate, firstStabPres, ...
            descentToParkEndDate, ...
            descentToProfStartDate, ...
            descentToProfEndDate, ...
            ascentStartDate, ...
            ascentEndDate, ...
            transStartDate, ...
            gpsDate, ...
            eolStartDate, ...
            firstGroundingDate, firstGroundingPres, ...
            secondGroundingDate, secondGroundingPres, ...
            firstEmergencyAscentDate, firstEmergencyAscentPres, ...
            descProfDate, descProfPres, ...
            parkDate, parkPres, ...
            ascProfDate, ascProfPres, ...
            nearSurfDate, nearSurfPres, ...
            inAirDate, inAirPres, ...
            evAct, pumpAct, 3);
         
         % print descending profile in CSV file
         print_desc_profile_in_csv_file_201_to_203_206_to_208_213_to_218( ...
            descProfDate, descProfPres, descProfTemp, descProfSal, ...
            descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, descProfDoxy);
         
         % print drift measurements in CSV file
         print_drift_meas_in_csv_file_201_to_203_206_to_208_213_to_218( ...
            parkDate, parkTransDate, ...
            parkPres, parkTemp, parkSal, ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, parkDoxy);
         
         % print ascending profile in CSV file
         print_asc_profile_in_csv_file_201_to_203_206_to_208_213_to_218( ...
            ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
            ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ascProfDoxy);
         
         % print "near surface" and "in air" measurements in CSV file
         print_in_air_meas_in_csv_file_210_to_217( ...
            nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, nearSurfPpoxDoxy, ...
            inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, inAirPpoxDoxy);
         
         % print EV and pump data in CSV file
         print_hydraulic_data_in_csv_file_201_to_203_215_216(evAct, pumpAct, 3);
         
         % print float parameters in CSV file
         print_float_prog_param_in_csv_file_216(floatParam1);
         
      else
         
         % output NetCDF files
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % PROF NetCDF file
         
         % process profile data for PROF NetCDF file
         tabProfiles = [];
         if ~(isempty(descProfPres) && isempty(ascProfPres))
            
            [tabProfiles] = process_profiles_216_218( ...
               descProfDate, descProfPres, descProfTemp, descProfSal, ...
               descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, descProfDoxy, ...
               ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
               ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ascProfDoxy, ...
               g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
               descentToParkStartDate, ascentEndDate, transStartDate, ...
               tabTech2, iceDetected, a_decoderId);
            
            % add the vertical sampling scheme from configuration
            % information
            [tabProfiles] = add_vertical_sampling_scheme_ir_sbd(tabProfiles, a_decoderId);
            
            print = 0;
            if (print == 1)
               if (~isempty(tabProfiles))
                  fprintf('DEC_INFO: Float #%d Cycle #%d: %d profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum, length(tabProfiles));
                  for idP = 1:length(tabProfiles)
                     prof = tabProfiles(idP);
                     paramList = prof.paramList;
                     paramList = sprintf('%s ', paramList.name);
                     profLength = size(prof.data, 1);
                     fprintf('   ->%2d: dir=%c length=%d param=(%s)\n', ...
                        idP, prof.direction, ...
                        profLength, paramList(1:end-1));
                  end
               else
                  fprintf('DEC_INFO: Float #%d Cycle #%d: No profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum);
               end
            end
            
            tabBuffProfiles = [tabBuffProfiles tabProfiles];
         end
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TRAJ NetCDF file
         
         % process trajectory data for TRAJ NetCDF file
         [tabTrajNMeas, tabTrajNCycle, tabTechNMeas] = process_trajectory_data_216( ...
            g_decArgo_cycleNum, deepCycleFlag, ...
            g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
            cycleStartDate, ...
            descentToParkStartDate, firstStabDate, firstStabPres, descentToParkEndDate, ...
            descentToProfStartDate, descentToProfEndDate, ...
            ascentStartDate, ascentEndDate, ...
            transStartDate, ...
            firstGroundingDate, firstGroundingPres, ...
            secondGroundingDate, secondGroundingPres, ...
            tabTech1, tabTech2, ...
            tabProfiles, ...
            parkDate, parkTransDate, ...
            parkPres, parkTemp, parkSal, ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, parkDoxy, ...
            nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, nearSurfPpoxDoxy, ...
            inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, inAirPpoxDoxy, ...
            evAct, pumpAct, iceDetected, a_decoderId);
         
         % sort trajectory data structures according to the predefined
         % measurement code order
         [tabTrajNMeas] = sort_trajectory_data(tabTrajNMeas, a_decoderId);
         
         tabBuffTrajNMeas = [tabBuffTrajNMeas tabTrajNMeas];
         tabBuffTrajNCycle = [tabBuffTrajNCycle tabTrajNCycle];
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TECH NetCDF file
         
         % store information on received Iridium packet types
         if (deepCycleFlag == 1)
            store_received_packet_type_info_for_nc(a_decoderId);
         end
         
         % store NetCDF technical data
         store_tech1_data_for_nc_201_to_203_215_216_218(tabTech1, deepCycleFlag);
         store_tech2_data_for_nc_216(tabTech2, deepCycleFlag, iceDetected);
         
         % store additional technical decoding information (for TECH_AUX
         % file)
         store_misc_tech_data_for_nc_212_214_216_to_218_222_to_225(a_decodedDataTab, a_decoderId);
         
         tabBuffNcTechIndex = [tabBuffNcTechIndex; g_decArgo_outputNcParamIndex];
         tabBuffNcTechVal = [tabBuffNcTechVal g_decArgo_outputNcParamValue];
         tabBuffTechNMeas = [tabBuffTechNMeas tabTechNMeas];
         
         g_decArgo_outputNcParamIndex = [];
         g_decArgo_outputNcParamValue = [];
         
      end
      
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   case {218} % Arvor-Deep-Ice Iridium 5.66 (NKE version)
      
      % get decoded data
      [tabTech1, tabTech2, ...
         dataCTD, dataCTDO, ...
         ~, ~, ...
         evAct, pumpAct, ...
         floatParam1, floatParam2] = ...
         get_decoded_data(a_decodedDataTab, a_decoderId);
      
      % assign the current configuration to the current deep cycle
      if ((g_decArgo_cycleNum > 0) && ((deepCycleFlag == 1) || (resetDetectedFlag == 1)))
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
      end
      
      % update float configuration for the next cycles
      if ~(isempty(floatParam1) && isempty(floatParam2))
         update_float_config_ir_sbd_delayed([{floatParam1} {floatParam2}], g_decArgo_cycleNum, a_decoderId);
      end
      if (g_decArgo_cycleNum == -1)
         % only consider parameter packets for cycle number -1
         return
      end
      
      % assign the configuration received during the prelude to this cycle
      if (g_decArgo_cycleNum == 0)
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
      end
      
      % store GPS data and compute JAMSTEC QC for the GPS locations of the
      % current cycle
      store_gps_data_ir_sbd(tabTech1, g_decArgo_cycleNum, a_decoderId);
      
      % convert counts to physical values
      if (~isempty(dataCTD))
         [dataCTD(:, 33:47)] = sensor_2_value_for_pressure_201_203_215_216_218_221(dataCTD(:, 33:47));
         [dataCTD(:, 48:62)] = sensor_2_value_for_temperature_201_to_203_215_216_218_221(dataCTD(:, 48:62));
         [dataCTD(:, 63:77)] = sensor_2_value_for_salinity_201_to_203_215_216_218_221(dataCTD(:, 63:77));
      end
      if (~isempty(dataCTDO))
         [dataCTDO(:, 17:23)] = sensor_2_value_for_pressure_201_203_215_216_218_221(dataCTDO(:, 17:23));
         [dataCTDO(:, 24:30)] = sensor_2_value_for_temperature_201_to_203_215_216_218_221(dataCTDO(:, 24:30));
         [dataCTDO(:, 31:37)] = sensor_2_value_for_salinity_201_to_203_215_216_218_221(dataCTDO(:, 31:37));
         [dataCTDO(:, 38:51)] = sensor_2_value_for_C1C2phase_ir_sbd_2xx(dataCTDO(:, 38:51));
         [dataCTDO(:, 52:58)] = sensor_2_value_for_temp_doxy_ir_sbd_2xx(dataCTDO(:, 52:58));
      end
      
      % create drift data set
      [parkDate, parkTransDate, ...
         parkPres, parkTemp, parkSal, ...
         parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy] = ...
         create_prv_drift_201_to_203_215_216_218_221(dataCTD, dataCTDO, 2);
      
      % create descending and ascending profiles
      [descProfDate, descProfPres, descProfTemp, descProfSal, ...
         descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, ...
         ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
         ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ...
         nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
         nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, ...
         inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
         inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy] = ...
         create_prv_profile_215_216_218_221(dataCTD, dataCTDO, 2);
      
      % compute DOXY
      descProfDoxy = [];
      parkDoxy = [];
      ascProfDoxy = [];
      nearSurfPpoxDoxy = [];
      inAirPpoxDoxy = [];
      if (~isempty(dataCTDO))
         
         % C1/2PHASE_DOXY -> DOXY using third method: "Stern-Volmer equation"
         [descProfDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, ...
            descProfPres, descProfTemp, descProfSal);
         [parkDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, ...
            parkPres, parkTemp, parkSal);
         [ascProfDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ...
            ascProfPres, ascProfTemp, ascProfSal);
         
         % compute PPOX_DOXY from C1PHASE_DOXY and C2PHASE_DOXY using the Stern-Volmer equation
         [nearSurfPpoxDoxy] = compute_PPOX_DOXY_213_to_218_221_223_225( ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, ...
            g_decArgo_c1C2PhaseDoxyDef, g_decArgo_c1C2PhaseDoxyDef, g_decArgo_tempDoxyDef, ...
            nearSurfPres, nearSurfTemp, ...
            g_decArgo_presDef, g_decArgo_tempDef, ...
            g_decArgo_doxyDef);
         [inAirPpoxDoxy] = compute_PPOX_DOXY_213_to_218_221_223_225( ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, ...
            g_decArgo_c1C2PhaseDoxyDef, g_decArgo_c1C2PhaseDoxyDef, g_decArgo_tempDoxyDef, ...
            inAirPres, inAirTemp, ...
            g_decArgo_presDef, g_decArgo_tempDef, ...
            g_decArgo_doxyDef);
      end
      
      % compute the main dates of the cycle
      [cycleStartDate, ...
         descentToParkStartDate, ...
         firstStabDate, firstStabPres, ...
         descentToParkEndDate, ...
         descentToProfStartDate, ...
         descentToProfEndDate, ...
         ascentStartDate, ...
         ascentEndDate, ...
         transStartDate, ...
         gpsDate, ...
         eolStartDate, ...
         firstGroundingDate, firstGroundingPres, ...
         secondGroundingDate, secondGroundingPres, ...
         firstEmergencyAscentDate, firstEmergencyAscentPres, ...
         iceDetected] = ...
         compute_prv_dates_216_218(tabTech1, tabTech2, deepCycleFlag, iceDelayedCycleFlag, a_refDay);
      
      if (~isempty(g_decArgo_outputCsvFileId))
         
         % output CSV file
         
         % print float technical messages in CSV file
         print_tech_data_in_csv_file_218(tabTech1, tabTech2, deepCycleFlag);
         
         % print dated data in CSV file
         print_dates_in_csv_file_218( ...
            cycleStartDate, ...
            descentToParkStartDate, ...
            firstStabDate, firstStabPres, ...
            descentToParkEndDate, ...
            descentToProfStartDate, ...
            descentToProfEndDate, ...
            ascentStartDate, ...
            ascentEndDate, ...
            transStartDate, ...
            gpsDate, ...
            eolStartDate, ...
            firstGroundingDate, firstGroundingPres, ...
            secondGroundingDate, secondGroundingPres, ...
            firstEmergencyAscentDate, firstEmergencyAscentPres, ...
            descProfDate, descProfPres, ...
            parkDate, parkPres, ...
            ascProfDate, ascProfPres, ...
            nearSurfDate, nearSurfPres, ...
            inAirDate, inAirPres, ...
            evAct, pumpAct);
         
         % print descending profile in CSV file
         print_desc_profile_in_csv_file_201_to_203_206_to_208_213_to_218( ...
            descProfDate, descProfPres, descProfTemp, descProfSal, ...
            descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, descProfDoxy);
         
         % print drift measurements in CSV file
         print_drift_meas_in_csv_file_201_to_203_206_to_208_213_to_218( ...
            parkDate, parkTransDate, ...
            parkPres, parkTemp, parkSal, ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, parkDoxy);
         
         % print ascending profile in CSV file
         print_asc_profile_in_csv_file_201_to_203_206_to_208_213_to_218( ...
            ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
            ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ascProfDoxy);
         
         % print "near surface" and "in air" measurements in CSV file
         print_in_air_meas_in_csv_file_210_to_217( ...
            nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, nearSurfPpoxDoxy, ...
            inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, inAirPpoxDoxy);
         
         % print EV and pump data in CSV file
         print_hydraulic_data_in_csv_file_212_214_217_218(evAct, pumpAct);
         
         % print float parameters in CSV file
         print_float_prog_param_in_csv_file_218(floatParam1, floatParam2);
         
      else
         
         % output NetCDF files
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % PROF NetCDF file
         
         % process profile data for PROF NetCDF file
         tabProfiles = [];
         if ~(isempty(descProfPres) && isempty(ascProfPres))
            
            [tabProfiles] = process_profiles_216_218( ...
               descProfDate, descProfPres, descProfTemp, descProfSal, ...
               descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, descProfDoxy, ...
               ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
               ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ascProfDoxy, ...
               g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
               descentToParkStartDate, ascentEndDate, transStartDate, ...
               tabTech2, iceDetected, a_decoderId);
            
            % add the vertical sampling scheme from configuration
            % information
            [tabProfiles] = add_vertical_sampling_scheme_ir_sbd(tabProfiles, a_decoderId);
            
            print = 0;
            if (print == 1)
               if (~isempty(tabProfiles))
                  fprintf('DEC_INFO: Float #%d Cycle #%d: %d profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum, length(tabProfiles));
                  for idP = 1:length(tabProfiles)
                     prof = tabProfiles(idP);
                     paramList = prof.paramList;
                     paramList = sprintf('%s ', paramList.name);
                     profLength = size(prof.data, 1);
                     fprintf('   ->%2d: dir=%c length=%d param=(%s)\n', ...
                        idP, prof.direction, ...
                        profLength, paramList(1:end-1));
                  end
               else
                  fprintf('DEC_INFO: Float #%d Cycle #%d: No profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum);
               end
            end
            
            tabBuffProfiles = [tabBuffProfiles tabProfiles];
         end
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TRAJ NetCDF file
         
         % process trajectory data for TRAJ NetCDF file
         [tabTrajNMeas, tabTrajNCycle, tabTechNMeas] = process_trajectory_data_218( ...
            g_decArgo_cycleNum, deepCycleFlag, ...
            g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
            cycleStartDate, ...
            descentToParkStartDate, firstStabDate, firstStabPres, descentToParkEndDate, ...
            descentToProfStartDate, descentToProfEndDate, ...
            ascentStartDate, ascentEndDate, ...
            transStartDate, ...
            firstGroundingDate, firstGroundingPres, ...
            secondGroundingDate, secondGroundingPres, ...
            tabTech1, tabTech2, ...
            tabProfiles, ...
            parkDate, parkTransDate, ...
            parkPres, parkTemp, parkSal, ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, parkDoxy, ...
            nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, nearSurfPpoxDoxy, ...
            inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, inAirPpoxDoxy, ...
            evAct, pumpAct, iceDetected, a_decoderId);
         
         % sort trajectory data structures according to the predefined
         % measurement code order
         [tabTrajNMeas] = sort_trajectory_data(tabTrajNMeas, a_decoderId);
         
         tabBuffTrajNMeas = [tabBuffTrajNMeas tabTrajNMeas];
         tabBuffTrajNCycle = [tabBuffTrajNCycle tabTrajNCycle];
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TECH NetCDF file
         
         % store information on received Iridium packet types
         if (deepCycleFlag == 1)
            store_received_packet_type_info_for_nc(a_decoderId);
         end
         
         % store NetCDF technical data
         store_tech1_data_for_nc_201_to_203_215_216_218(tabTech1, deepCycleFlag);
         store_tech2_data_for_nc_218(tabTech2, deepCycleFlag, iceDetected);
         
         % store additional technical decoding information (for TECH_AUX
         % file)
         store_misc_tech_data_for_nc_212_214_216_to_218_222_to_225(a_decodedDataTab, a_decoderId);
         
         tabBuffNcTechIndex = [tabBuffNcTechIndex; g_decArgo_outputNcParamIndex];
         tabBuffNcTechVal = [tabBuffNcTechVal g_decArgo_outputNcParamValue];
         tabBuffTechNMeas = [tabBuffTechNMeas tabTechNMeas];
         
         g_decArgo_outputNcParamIndex = [];
         g_decArgo_outputNcParamValue = [];
         
      end
      
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   case {221} % Arvor-Deep-Ice Iridium 5.67
      
      % get decoded data
      [tabTech1, tabTech2, ...
         dataCTD, dataCTDO, ...
         ~, ~, ...
         evAct, pumpAct, ...
         floatParam1, floatParam2] = ...
         get_decoded_data(a_decodedDataTab, a_decoderId);
      
      % assign the current configuration to the current deep cycle
      if ((g_decArgo_cycleNum > 0) && ((deepCycleFlag == 1) || (resetDetectedFlag == 1)))
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
         
         % update the configuration (even if no param packets are received)       
         if (g_decArgo_doneOnceFlag ~= 1)
            update_float_config_ir_sbd_delayed([{[]} {[]}], g_decArgo_cycleNum, a_decoderId);
         end
      end
      
      % update float configuration for the next cycles
      if ~(isempty(floatParam1) && isempty(floatParam2))
         update_float_config_ir_sbd_delayed([{floatParam1} {floatParam2}], g_decArgo_cycleNum, a_decoderId);
      end
      if (g_decArgo_cycleNum == -1)
         % only consider parameter packets for cycle number -1
         return
      end
      
      % assign the configuration received during the prelude to this cycle
      if (g_decArgo_cycleNum == 0)
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
      end
      
      % store GPS data and compute JAMSTEC QC for the GPS locations of the
      % current cycle
      store_gps_data_ir_sbd(tabTech1, g_decArgo_cycleNum, a_decoderId);
      
      % convert counts to physical values
      if (~isempty(dataCTD))
         [dataCTD(:, 33:47)] = sensor_2_value_for_pressure_201_203_215_216_218_221(dataCTD(:, 33:47));
         [dataCTD(:, 48:62)] = sensor_2_value_for_temperature_201_to_203_215_216_218_221(dataCTD(:, 48:62));
         [dataCTD(:, 63:77)] = sensor_2_value_for_salinity_201_to_203_215_216_218_221(dataCTD(:, 63:77));
      end
      if (~isempty(dataCTDO))
         [dataCTDO(:, 17:23)] = sensor_2_value_for_pressure_201_203_215_216_218_221(dataCTDO(:, 17:23));
         [dataCTDO(:, 24:30)] = sensor_2_value_for_temperature_201_to_203_215_216_218_221(dataCTDO(:, 24:30));
         [dataCTDO(:, 31:37)] = sensor_2_value_for_salinity_201_to_203_215_216_218_221(dataCTDO(:, 31:37));
         [dataCTDO(:, 38:51)] = sensor_2_value_for_C1C2phase_ir_sbd_2xx(dataCTDO(:, 38:51));
         [dataCTDO(:, 52:58)] = sensor_2_value_for_temp_doxy_ir_sbd_2xx(dataCTDO(:, 52:58));
      end
      
      % create drift data set
      [parkDate, parkTransDate, ...
         parkPres, parkTemp, parkSal, ...
         parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy] = ...
         create_prv_drift_201_to_203_215_216_218_221(dataCTD, dataCTDO, 2);
      
      % create descending and ascending profiles
      [descProfDate, descProfPres, descProfTemp, descProfSal, ...
         descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, ...
         ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
         ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ...
         nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
         nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, ...
         inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
         inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy] = ...
         create_prv_profile_215_216_218_221(dataCTD, dataCTDO, 2);
      
      % compute DOXY
      descProfDoxy = [];
      parkDoxy = [];
      ascProfDoxy = [];
      nearSurfPpoxDoxy = [];
      inAirPpoxDoxy = [];
      if (~isempty(dataCTDO))
         
         % C1/2PHASE_DOXY -> DOXY using third method: "Stern-Volmer equation"
         [descProfDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, ...
            descProfPres, descProfTemp, descProfSal);
         [parkDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, ...
            parkPres, parkTemp, parkSal);
         [ascProfDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ...
            ascProfPres, ascProfTemp, ascProfSal);
         
         % compute PPOX_DOXY from C1PHASE_DOXY and C2PHASE_DOXY using the Stern-Volmer equation
         [nearSurfPpoxDoxy] = compute_PPOX_DOXY_213_to_218_221_223_225( ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, ...
            g_decArgo_c1C2PhaseDoxyDef, g_decArgo_c1C2PhaseDoxyDef, g_decArgo_tempDoxyDef, ...
            nearSurfPres, nearSurfTemp, ...
            g_decArgo_presDef, g_decArgo_tempDef, ...
            g_decArgo_doxyDef);
         [inAirPpoxDoxy] = compute_PPOX_DOXY_213_to_218_221_223_225( ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, ...
            g_decArgo_c1C2PhaseDoxyDef, g_decArgo_c1C2PhaseDoxyDef, g_decArgo_tempDoxyDef, ...
            inAirPres, inAirTemp, ...
            g_decArgo_presDef, g_decArgo_tempDef, ...
            g_decArgo_doxyDef);
      end
      
      % compute the main dates of the cycle
      cycleTimeData = compute_prv_dates_221( ...
         tabTech1, tabTech2, deepCycleFlag, iceDelayedCycleFlag, a_refDay, g_decArgo_cycleNum);
      
      % apply clock offset adjustment
      [parkDateAdj, descProfDateAdj, ascProfDateAdj, ...
         nearSurfDateAdj, inAirDateAdj, evAct, pumpAct, cycleTimeData] = adjust_clock_offset_prv_ir( ...
         parkDate, descProfDate, ascProfDate, nearSurfDate, inAirDate, ...
         evAct, pumpAct, ...
         cycleTimeData, g_decArgo_clockOffset);

      if (~isempty(g_decArgo_outputCsvFileId))
         
         % output CSV file
         
         % print float technical messages in CSV file
         print_tech_data_in_csv_file_221(tabTech1, tabTech2, deepCycleFlag);

         % print dated data in CSV file
         print_dates_in_csv_file_221_to_225( ...
            cycleTimeData, ...
            descProfDate, descProfDateAdj, descProfPres, ...
            parkDate, parkDateAdj, parkPres, ...
            ascProfDate, ascProfDateAdj, ascProfPres, ...
            nearSurfDate, nearSurfDateAdj, nearSurfPres, ...
            inAirDate, inAirDateAdj, inAirPres, ...
            evAct, pumpAct);
         
         % print descending profile in CSV file
         print_descending_profile_in_csv_file_221_222_223_225( ...
            descProfDate, descProfDateAdj, descProfPres, descProfTemp, descProfSal, ...
            descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, descProfDoxy);
         
         % print drift measurements in CSV file
         print_drift_measurements_in_csv_file_221_222_223_225( ...
            parkDate, parkDateAdj, parkTransDate, ...
            parkPres, parkTemp, parkSal, ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, parkDoxy);
         
         % print ascending profile in CSV file
         print_ascending_profile_in_csv_file_221_222_223_225( ...
            ascProfDate, ascProfDateAdj, ascProfPres, ascProfTemp, ascProfSal, ...
            ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ascProfDoxy);
         
         % print "near surface" and "in air" measurements in CSV file
         print_in_air_meas_in_csv_file_221_222_223_225( ...
            nearSurfDate, nearSurfDateAdj, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, nearSurfPpoxDoxy, ...
            inAirDate, inAirDateAdj, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, inAirPpoxDoxy);
         
         % print EV and pump data in CSV file
         print_hydraulic_data_in_csv_file_221_222_223_225(evAct, pumpAct);
         
         % print float parameters in CSV file
         print_float_prog_param_in_csv_file_221(floatParam1, floatParam2);
         
      else
         
         % output NetCDF files
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % PROF NetCDF file
         
         % process profile data for PROF NetCDF file
         tabProfiles = [];
         if ~(isempty(descProfPres) && isempty(ascProfPres))
            
            [tabProfiles] = process_profiles_221( ...
               descProfDate, descProfDateAdj, descProfPres, descProfTemp, descProfSal, ...
               descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, descProfDoxy, ...
               ascProfDate, ascProfDateAdj, ascProfPres, ascProfTemp, ascProfSal, ...
               ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ascProfDoxy, ...
               g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
               cycleTimeData, ...
               tabTech2, a_decoderId);
            
            % add the vertical sampling scheme from configuration
            % information
            [tabProfiles] = add_vertical_sampling_scheme_ir_sbd(tabProfiles, a_decoderId);
            
            print = 0;
            if (print == 1)
               if (~isempty(tabProfiles))
                  fprintf('DEC_INFO: Float #%d Cycle #%d: %d profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum, length(tabProfiles));
                  for idP = 1:length(tabProfiles)
                     prof = tabProfiles(idP);
                     paramList = prof.paramList;
                     paramList = sprintf('%s ', paramList.name);
                     profLength = size(prof.data, 1);
                     fprintf('   ->%2d: dir=%c length=%d param=(%s)\n', ...
                        idP, prof.direction, ...
                        profLength, paramList(1:end-1));
                  end
               else
                  fprintf('DEC_INFO: Float #%d Cycle #%d: No profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum);
               end
            end
            
            tabBuffProfiles = [tabBuffProfiles tabProfiles];
         end
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TRAJ NetCDF file
         
         % process trajectory data for TRAJ NetCDF file
         [tabTrajNMeas, tabTrajNCycle, tabTechNMeas] = process_trajectory_data_221( ...
            g_decArgo_cycleNum, deepCycleFlag, ...
            g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
            cycleTimeData, ...
            tabTech1, tabTech2, ...
            tabProfiles, ...
            parkDate, parkTransDate, ...
            parkPres, parkTemp, parkSal, ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, parkDoxy, ...
            nearSurfDate, nearSurfTransDate, ...
            nearSurfPres, nearSurfTemp, nearSurfSal, ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, nearSurfPpoxDoxy, ...
            inAirDate, inAirTransDate, ...
            inAirPres, inAirTemp, inAirSal, ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, inAirPpoxDoxy, ...
            evAct, pumpAct);
         
         % sort trajectory data structures according to the predefined
         % measurement code order
         [tabTrajNMeas] = sort_trajectory_data(tabTrajNMeas, a_decoderId);
         
         tabBuffTrajNMeas = [tabBuffTrajNMeas tabTrajNMeas];
         tabBuffTrajNCycle = [tabBuffTrajNCycle tabTrajNCycle];
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TECH NetCDF file
         
         % store information on received Iridium packet types
         if (deepCycleFlag == 1)
            store_received_packet_type_info_for_nc(a_decoderId);
         end
         
         % store NetCDF technical data
         store_tech1_data_for_nc_221(tabTech1, deepCycleFlag);
         store_tech2_data_for_nc_221(tabTech2, deepCycleFlag, cycleTimeData.iceDetected);
         
         % store additional technical decoding information (for TECH_AUX
         % file)
         store_misc_tech_data_for_nc_212_214_216_to_218_222_to_225(a_decodedDataTab, a_decoderId);
         
         tabBuffNcTechIndex = [tabBuffNcTechIndex; g_decArgo_outputNcParamIndex];
         tabBuffNcTechVal = [tabBuffNcTechVal g_decArgo_outputNcParamValue];
         tabBuffTechNMeas = [tabBuffTechNMeas tabTechNMeas];
         
         g_decArgo_outputNcParamIndex = [];
         g_decArgo_outputNcParamValue = [];
      end
      
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   case {222} % Arvor-ARN-Ice Iridium 5.47
      
      % get decoded data
      [tabTech1, tabTech2, ...
         dataCTD, ~, ...
         ~, ~, ...
         evAct, pumpAct, ...
         floatParam1, floatParam2] = ...
         get_decoded_data(a_decodedDataTab, a_decoderId);
      
      % assign the current configuration to the current deep cycle
      if ((g_decArgo_cycleNum > 0) && ((deepCycleFlag == 1) || (resetDetectedFlag == 1)))
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
         
         % update the configuration (even if no param packets are received)       
         if (g_decArgo_doneOnceFlag ~= 1)
            update_float_config_ir_sbd_delayed([{[]} {[]}], g_decArgo_cycleNum, a_decoderId);
         end
      end
      
      % update float configuration for the next cycles
      if ~(isempty(floatParam1) && isempty(floatParam2))
         update_float_config_ir_sbd_delayed([{floatParam1} {floatParam2}], g_decArgo_cycleNum, a_decoderId);
      end
      if (g_decArgo_cycleNum == -1)
         % only consider parameter packets for cycle number -1
         return
      end
      
      % assign the configuration received during the prelude to this cycle
      if (g_decArgo_cycleNum == 0)
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
      end
      
      % store GPS data and compute JAMSTEC QC for the GPS locations of the
      % current cycle
      store_gps_data_ir_sbd(tabTech1, g_decArgo_cycleNum, a_decoderId);
      
      % convert counts to physical values
      if (~isempty(dataCTD))
         [dataCTD(:, 33:47)] = sensor_2_value_for_pressure_202_210_to_214_217_222_to_225(dataCTD(:, 33:47));
         [dataCTD(:, 48:62)] = sensor_2_value_for_temp_204_to_214_217_219_220_222_to_225(dataCTD(:, 48:62));
         [dataCTD(:, 63:77)] = sensor_2_value_for_salinity_210_to_214_217_220_222_to_225(dataCTD(:, 63:77));
      end
      
      % create drift data set
      [parkDate, parkTransDate, ...
         parkPres, parkTemp, parkSal] = ...
         create_prv_drift_212_222(dataCTD, g_decArgo_julD2FloatDayOffset);
      
      % create descending and ascending profiles
      [descProfDate, descProfPres, descProfTemp, descProfSal, ...
         ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
         nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
         inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal] = ...
         create_prv_profile_212_222(dataCTD, deepCycleFlag, g_decArgo_julD2FloatDayOffset);
                 
      % compute the main dates of the cycle
      cycleTimeData = compute_prv_dates_222_to_225( ...
         tabTech1, tabTech2, deepCycleFlag, iceDelayedCycleFlag, a_refDay, g_decArgo_cycleNum);
      
      % apply clock offset adjustment
      [parkDateAdj, descProfDateAdj, ascProfDateAdj, ...
         nearSurfDateAdj, inAirDateAdj, evAct, pumpAct, cycleTimeData] = adjust_clock_offset_prv_ir( ...
         parkDate, descProfDate, ascProfDate, nearSurfDate, inAirDate, ...
         evAct, pumpAct, ...
         cycleTimeData, g_decArgo_clockOffset);

      if (~isempty(g_decArgo_outputCsvFileId))
         
         % output CSV file
         
         % print float technical messages in CSV file
         print_tech_data_in_csv_file_222_223_225(tabTech1, tabTech2, deepCycleFlag);
         
         % print dated data in CSV file
         print_dates_in_csv_file_221_to_225( ...
            cycleTimeData, ...
            descProfDate, descProfDateAdj, descProfPres, ...
            parkDate, parkDateAdj, parkPres, ...
            ascProfDate, ascProfDateAdj, ascProfPres, ...
            nearSurfDate, nearSurfDateAdj, nearSurfPres, ...
            inAirDate, inAirDateAdj, inAirPres, ...
            evAct, pumpAct);
         
         % print descending profile in CSV file
         print_descending_profile_in_csv_file_221_222_223_225( ...
            descProfDate, descProfDateAdj, descProfPres, descProfTemp, descProfSal, ...
            [], [], [], []);
         
         % print drift measurements in CSV file
         print_drift_measurements_in_csv_file_221_222_223_225( ...
            parkDate, parkDateAdj, parkTransDate, ...
            parkPres, parkTemp, parkSal, ...
            [], [], [], []);

         % print ascending profile in CSV file
         print_ascending_profile_in_csv_file_221_222_223_225( ...
            ascProfDate, ascProfDateAdj, ascProfPres, ascProfTemp, ascProfSal, ...
            [], [], [], []);
         
         % print "near surface" and "in air" measurements in CSV file
         print_in_air_meas_in_csv_file_221_222_223_225( ...
            nearSurfDate, nearSurfDateAdj, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
            [], [], [], [], ...
            inAirDate, inAirDateAdj, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
            [], [], [], []);
         
         % print EV and pump data in CSV file
         print_hydraulic_data_in_csv_file_221_222_223_225(evAct, pumpAct);

         % print float parameters in CSV file
         print_float_prog_param_in_csv_file_222_223_225(floatParam1, floatParam2);
         
      else
         
         % output NetCDF files
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % PROF NetCDF file
         
         % process profile data for PROF NetCDF file
         tabProfiles = [];
         if (~isempty(dataCTD))
            
            [tabProfiles] = process_profiles_222_223_225( ...
               descProfDate, descProfDateAdj, descProfPres, descProfTemp, descProfSal, ...
               [], [], [], [], ...
               ascProfDate, ascProfDateAdj, ascProfPres, ascProfTemp, ascProfSal, ...
               [], [], [], [], ...
               g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
               cycleTimeData, ...
               tabTech2, a_decoderId);

            % add the vertical sampling scheme from configuration
            % information
            [tabProfiles] = add_vertical_sampling_scheme_ir_sbd(tabProfiles, a_decoderId);
            
            print = 0;
            if (print == 1)
               if (~isempty(tabProfiles))
                  fprintf('DEC_INFO: Float #%d Cycle #%d: %d profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum, length(tabProfiles));
                  for idP = 1:length(tabProfiles)
                     prof = tabProfiles(idP);
                     paramList = prof.paramList;
                     paramList = sprintf('%s ', paramList.name);
                     profLength = size(prof.data, 1);
                     fprintf('   ->%2d: dir=%c length=%d param=(%s)\n', ...
                        idP, prof.direction, ...
                        profLength, paramList(1:end-1));
                  end
               else
                  fprintf('DEC_INFO: Float #%d Cycle #%d: No profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum);
               end
            end
            
            tabBuffProfiles = [tabBuffProfiles tabProfiles];
         end
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TRAJ NetCDF file
                  
         % process trajectory data for TRAJ NetCDF file
         [tabTrajNMeas, tabTrajNCycle, tabTechNMeas] = process_trajectory_data_222_223_225( ...
            g_decArgo_cycleNum, deepCycleFlag, ...
            g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
            cycleTimeData, ...
            tabTech1, tabTech2, ...
            tabProfiles, ...
            parkDate, parkTransDate, ...
            parkPres, parkTemp, parkSal, ...
            [], [], [], [], ...
            nearSurfDate, nearSurfTransDate, ...
            nearSurfPres, nearSurfTemp, nearSurfSal, ...
            [], [], [], [], ...
            inAirDate, inAirTransDate, ...
            inAirPres, inAirTemp, inAirSal, ...
            [], [], [], [], ...
            evAct, pumpAct);

         % sort trajectory data structures according to the predefined
         % measurement code order
         [tabTrajNMeas] = sort_trajectory_data(tabTrajNMeas, a_decoderId);
         
         tabBuffTrajNMeas = [tabBuffTrajNMeas tabTrajNMeas];
         tabBuffTrajNCycle = [tabBuffTrajNCycle tabTrajNCycle];
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TECH NetCDF file
         
         % store information on received Iridium packet types
         if (deepCycleFlag == 1)
            store_received_packet_type_info_for_nc(a_decoderId);
         end
         
         % store NetCDF technical data
         store_tech1_data_for_nc_222_to_225(tabTech1, deepCycleFlag);
         store_tech2_data_for_nc_212_214_217_222_223_225(tabTech2, deepCycleFlag, cycleTimeData.iceDetected);
         
         % store additional technical decoding information (for TECH_AUX
         % file)
         store_misc_tech_data_for_nc_212_214_216_to_218_222_to_225(a_decodedDataTab, a_decoderId);
         
         tabBuffNcTechIndex = [tabBuffNcTechIndex; g_decArgo_outputNcParamIndex];
         tabBuffNcTechVal = [tabBuffNcTechVal g_decArgo_outputNcParamValue];
         tabBuffTechNMeas = [tabBuffTechNMeas tabTechNMeas];
         
         g_decArgo_outputNcParamIndex = [];
         g_decArgo_outputNcParamValue = [];
         
      end
      
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   case {223, 225}
      % Arvor-ARN-DO-Ice Iridium 5.48
      % Provor-ARN-DO-Ice Iridium 5.76

      % get decoded data
      [tabTech1, tabTech2, ...
         dataCTD, dataCTDO, ...
         ~, ~, ...
         evAct, pumpAct, ...
         floatParam1, floatParam2] = ...
         get_decoded_data(a_decodedDataTab, a_decoderId);
      
      % assign the current configuration to the current deep cycle
      if ((g_decArgo_cycleNum > 0) && ((deepCycleFlag == 1) || (resetDetectedFlag == 1)))
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
         
         % update the configuration (even if no param packets are received)       
         if (g_decArgo_doneOnceFlag ~= 1)
            update_float_config_ir_sbd_delayed([{[]} {[]}], g_decArgo_cycleNum, a_decoderId);
         end
      end
      
      % update float configuration for the next cycles
      if ~(isempty(floatParam1) && isempty(floatParam2))
         update_float_config_ir_sbd_delayed([{floatParam1} {floatParam2}], g_decArgo_cycleNum, a_decoderId);
      end
      if (g_decArgo_cycleNum == -1)
         % only consider parameter packets for cycle number -1
         return
      end
      
      % assign the configuration received during the prelude to this cycle
      if (g_decArgo_cycleNum == 0)
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
      end
      
      % store GPS data and compute JAMSTEC QC for the GPS locations of the
      % current cycle
      store_gps_data_ir_sbd(tabTech1, g_decArgo_cycleNum, a_decoderId);
      
      % convert counts to physical values
      if (~isempty(dataCTD))
         [dataCTD(:, 33:47)] = sensor_2_value_for_pressure_202_210_to_214_217_222_to_225(dataCTD(:, 33:47));
         [dataCTD(:, 48:62)] = sensor_2_value_for_temp_204_to_214_217_219_220_222_to_225(dataCTD(:, 48:62));
         [dataCTD(:, 63:77)] = sensor_2_value_for_salinity_210_to_214_217_220_222_to_225(dataCTD(:, 63:77));
      end
      if (~isempty(dataCTDO))
         [dataCTDO(:, 17:23)] = sensor_2_value_for_pressure_202_210_to_214_217_222_to_225(dataCTDO(:, 17:23));
         [dataCTDO(:, 24:30)] = sensor_2_value_for_temp_204_to_214_217_219_220_222_to_225(dataCTDO(:, 24:30));
         [dataCTDO(:, 31:37)] = sensor_2_value_for_salinity_210_to_214_217_220_222_to_225(dataCTDO(:, 31:37));
         [dataCTDO(:, 38:51)] = sensor_2_value_for_C1C2phase_ir_sbd_2xx(dataCTDO(:, 38:51));
         [dataCTDO(:, 52:58)] = sensor_2_value_for_temp_doxy_ir_sbd_2xx(dataCTDO(:, 52:58));
      end
      
      % create drift data set
      [parkDate, parkTransDate, ...
         parkPres, parkTemp, parkSal, ...
         parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy] = ...
         create_prv_drift_214_217_223_225(dataCTD, dataCTDO, g_decArgo_julD2FloatDayOffset);

      % create descending and ascending profiles
      [descProfDate, descProfPres, descProfTemp, descProfSal, ...
         descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, ...
         ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ...
         ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ...
         nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
         nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, ...
         inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
         inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy] = ...
         create_prv_profile_214_217_223_225(dataCTD, dataCTDO, deepCycleFlag, g_decArgo_julD2FloatDayOffset);

      % compute DOXY
      descProfDoxy = [];
      parkDoxy = [];
      ascProfDoxy = [];
      nearSurfPpoxDoxy = [];
      inAirPpoxDoxy = [];
      if (~isempty(dataCTDO))
         
         % C1/2PHASE_DOXY -> DOXY using third method: "Stern-Volmer equation"
         [descProfDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, ...
            descProfPres, descProfTemp, descProfSal);
         [parkDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, ...
            parkPres, parkTemp, parkSal);
         [ascProfDoxy] = compute_DOXY_201_203_206_209_213_to_218_221_223_225( ...
            ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ...
            ascProfPres, ascProfTemp, ascProfSal);
         
         % compute PPOX_DOXY from C1PHASE_DOXY and C2PHASE_DOXY using the Stern-Volmer equation
         [nearSurfPpoxDoxy] = compute_PPOX_DOXY_213_to_218_221_223_225( ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, ...
            g_decArgo_c1C2PhaseDoxyDef, g_decArgo_c1C2PhaseDoxyDef, g_decArgo_tempDoxyDef, ...
            nearSurfPres, nearSurfTemp, ...
            g_decArgo_presDef, g_decArgo_tempDef, ...
            g_decArgo_doxyDef);
         [inAirPpoxDoxy] = compute_PPOX_DOXY_213_to_218_221_223_225( ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, ...
            g_decArgo_c1C2PhaseDoxyDef, g_decArgo_c1C2PhaseDoxyDef, g_decArgo_tempDoxyDef, ...
            inAirPres, inAirTemp, ...
            g_decArgo_presDef, g_decArgo_tempDef, ...
            g_decArgo_doxyDef);
      end
      
      % compute the main dates of the cycle
      cycleTimeData = compute_prv_dates_222_to_225( ...
         tabTech1, tabTech2, deepCycleFlag, iceDelayedCycleFlag, a_refDay, g_decArgo_cycleNum);
      
      % apply clock offset adjustment
      [parkDateAdj, descProfDateAdj, ascProfDateAdj, ...
         nearSurfDateAdj, inAirDateAdj, evAct, pumpAct, cycleTimeData] = adjust_clock_offset_prv_ir( ...
         parkDate, descProfDate, ascProfDate, nearSurfDate, inAirDate, ...
         evAct, pumpAct, ...
         cycleTimeData, g_decArgo_clockOffset);

      if (~isempty(g_decArgo_outputCsvFileId))
         
         % output CSV file
         
         % print float technical messages in CSV file
         print_tech_data_in_csv_file_222_223_225(tabTech1, tabTech2, deepCycleFlag);
         
         % print dated data in CSV file
         print_dates_in_csv_file_221_to_225( ...
            cycleTimeData, ...
            descProfDate, descProfDateAdj, descProfPres, ...
            parkDate, parkDateAdj, parkPres, ...
            ascProfDate, ascProfDateAdj, ascProfPres, ...
            nearSurfDate, nearSurfDateAdj, nearSurfPres, ...
            inAirDate, inAirDateAdj, inAirPres, ...
            evAct, pumpAct);
         
         % print descending profile in CSV file
         print_descending_profile_in_csv_file_221_222_223_225( ...
            descProfDate, descProfDateAdj, descProfPres, descProfTemp, descProfSal, ...
            descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, descProfDoxy);
         
         % print drift measurements in CSV file
         print_drift_measurements_in_csv_file_221_222_223_225( ...
            parkDate, parkDateAdj, parkTransDate, ...
            parkPres, parkTemp, parkSal, ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, parkDoxy);
         
         % print ascending profile in CSV file
         print_ascending_profile_in_csv_file_221_222_223_225( ...
            ascProfDate, ascProfDateAdj, ascProfPres, ascProfTemp, ascProfSal, ...
            ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ascProfDoxy);
         
         % print "near surface" and "in air" measurements in CSV file
         print_in_air_meas_in_csv_file_221_222_223_225( ...
            nearSurfDate, nearSurfDateAdj, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, nearSurfPpoxDoxy, ...
            inAirDate, inAirDateAdj, inAirTransDate, inAirPres, inAirTemp, inAirSal, ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, inAirPpoxDoxy);

         % print EV and pump data in CSV file
         print_hydraulic_data_in_csv_file_221_222_223_225(evAct, pumpAct);

         % print float parameters in CSV file
         print_float_prog_param_in_csv_file_222_223_225(floatParam1, floatParam2);
         
      else
         
         % output NetCDF files
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % PROF NetCDF file
         
         % process profile data for PROF NetCDF file
         tabProfiles = [];
         if ~(isempty(descProfPres) && isempty(ascProfPres))
            
            [tabProfiles] = process_profiles_222_223_225( ...
               descProfDate, descProfDateAdj, descProfPres, descProfTemp, descProfSal, ...
               descProfC1PhaseDoxy, descProfC2PhaseDoxy, descProfTempDoxy, descProfDoxy, ...
               ascProfDate, ascProfDateAdj, ascProfPres, ascProfTemp, ascProfSal, ...
               ascProfC1PhaseDoxy, ascProfC2PhaseDoxy, ascProfTempDoxy, ascProfDoxy, ...
               g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
               cycleTimeData, ...
               tabTech2, a_decoderId);

            % add the vertical sampling scheme from configuration
            % information
            [tabProfiles] = add_vertical_sampling_scheme_ir_sbd(tabProfiles, a_decoderId);
            
            print = 0;
            if (print == 1)
               if (~isempty(tabProfiles))
                  fprintf('DEC_INFO: Float #%d Cycle #%d: %d profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum, length(tabProfiles));
                  for idP = 1:length(tabProfiles)
                     prof = tabProfiles(idP);
                     paramList = prof.paramList;
                     paramList = sprintf('%s ', paramList.name);
                     profLength = size(prof.data, 1);
                     fprintf('   ->%2d: dir=%c length=%d param=(%s)\n', ...
                        idP, prof.direction, ...
                        profLength, paramList(1:end-1));
                  end
               else
                  fprintf('DEC_INFO: Float #%d Cycle #%d: No profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum);
               end
            end
            
            tabBuffProfiles = [tabBuffProfiles tabProfiles];
         end
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TRAJ NetCDF file
         
         % process trajectory data for TRAJ NetCDF file
         [tabTrajNMeas, tabTrajNCycle, tabTechNMeas] = process_trajectory_data_222_223_225( ...
            g_decArgo_cycleNum, deepCycleFlag, ...
            g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
            cycleTimeData, ...
            tabTech1, tabTech2, ...
            tabProfiles, ...
            parkDate, parkTransDate, ...
            parkPres, parkTemp, parkSal, ...
            parkC1PhaseDoxy, parkC2PhaseDoxy, parkTempDoxy, parkDoxy, ...
            nearSurfDate, nearSurfTransDate, ...
            nearSurfPres, nearSurfTemp, nearSurfSal, ...
            nearSurfC1PhaseDoxy, nearSurfC2PhaseDoxy, nearSurfTempDoxy, nearSurfPpoxDoxy, ...
            inAirDate, inAirTransDate, ...
            inAirPres, inAirTemp, inAirSal, ...
            inAirC1PhaseDoxy, inAirC2PhaseDoxy, inAirTempDoxy, inAirPpoxDoxy, ...
            evAct, pumpAct);

         % sort trajectory data structures according to the predefined
         % measurement code order
         [tabTrajNMeas] = sort_trajectory_data(tabTrajNMeas, a_decoderId);
         
         tabBuffTrajNMeas = [tabBuffTrajNMeas tabTrajNMeas];
         tabBuffTrajNCycle = [tabBuffTrajNCycle tabTrajNCycle];
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TECH NetCDF file
         
         % store information on received Iridium packet types
         if (deepCycleFlag == 1)
            store_received_packet_type_info_for_nc(a_decoderId);
         end
         
         % store NetCDF technical data
         store_tech1_data_for_nc_222_to_225(tabTech1, deepCycleFlag);
         store_tech2_data_for_nc_212_214_217_222_223_225(tabTech2, deepCycleFlag, cycleTimeData.iceDetected);
         
         % store additional technical decoding information (for TECH_AUX
         % file)
         store_misc_tech_data_for_nc_212_214_216_to_218_222_to_225(a_decodedDataTab, a_decoderId);
         
         tabBuffNcTechIndex = [tabBuffNcTechIndex; g_decArgo_outputNcParamIndex];
         tabBuffNcTechVal = [tabBuffNcTechVal g_decArgo_outputNcParamValue];
         tabBuffTechNMeas = [tabBuffTechNMeas tabTechNMeas];

         g_decArgo_outputNcParamIndex = [];
         g_decArgo_outputNcParamValue = [];
         
      end

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   case {224} % Arvor-ARN-Ice RBR Iridium 5.49
            
      % get decoded data
      [tabTech1, tabTech2, ...
         ~, ~, ...
         dataCTDRbr, ~, ...
         evAct, pumpAct, ...
         floatParam1, floatParam2] = ...
         get_decoded_data(a_decodedDataTab, a_decoderId);
      
      % assign the current configuration to the current deep cycle
      if ((g_decArgo_cycleNum > 0) && ((deepCycleFlag == 1) || (resetDetectedFlag == 1)))
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
         
         % update the configuration (even if no param packets are received)       
         if (g_decArgo_doneOnceFlag ~= 1)
            update_float_config_ir_sbd_delayed([{[]} {[]}], g_decArgo_cycleNum, a_decoderId);
         end
      end
      
      % update float configuration for the next cycles
      if ~(isempty(floatParam1) && isempty(floatParam2))
         update_float_config_ir_sbd_delayed([{floatParam1} {floatParam2}], g_decArgo_cycleNum, a_decoderId);
      end
      if (g_decArgo_cycleNum == -1)
         % only consider parameter packets for cycle number -1
         return
      end
      
      % assign the configuration received during the prelude to this cycle
      if (g_decArgo_cycleNum == 0)
         set_float_config_ir_sbd_delayed(g_decArgo_cycleNum);
      end
      
      % store GPS data and compute JAMSTEC QC for the GPS locations of the
      % current cycle
      store_gps_data_ir_sbd(tabTech1, g_decArgo_cycleNum, a_decoderId);
      
      % convert counts to physical values
      if (~isempty(dataCTDRbr))
         [dataCTDRbr(:, 25:35)] = sensor_2_value_for_pressure_202_210_to_214_217_222_to_225(dataCTDRbr(:, 25:35));
         [dataCTDRbr(:, 36:46)] = sensor_2_value_for_temp_204_to_214_217_219_220_222_to_225(dataCTDRbr(:, 36:46));
         [dataCTDRbr(:, 47:57)] = sensor_2_value_for_salinity_210_to_214_217_220_222_to_225(dataCTDRbr(:, 47:57));
         [dataCTDRbr(:, 58:68)] = sensor_2_value_for_temp_cndc_224(dataCTDRbr(:, 58:68));
      end
      
      % create drift data set
      [parkDate, parkTransDate, ...
         parkPres, parkTemp, parkSal, parkTempCndc] = ...
         create_prv_drift_224(dataCTDRbr, g_decArgo_julD2FloatDayOffset);
      
      % create descending and ascending profiles
      [descProfDate, descProfPres, descProfTemp, descProfSal, descProfTempCndc, ...
         ascProfDate, ascProfPres, ascProfTemp, ascProfSal, ascProfTempCndc, ...
         nearSurfDate, nearSurfTransDate, nearSurfPres, nearSurfTemp, nearSurfSal, nearSurfTempCndc, ...
         inAirDate, inAirTransDate, inAirPres, inAirTemp, inAirSal, inAirTempCndc] = ...
         create_prv_profile_224(dataCTDRbr, deepCycleFlag, g_decArgo_julD2FloatDayOffset);
                 
      % compute the main dates of the cycle
      cycleTimeData = compute_prv_dates_222_to_225( ...
         tabTech1, tabTech2, deepCycleFlag, iceDelayedCycleFlag, a_refDay, g_decArgo_cycleNum);
      
      % apply clock offset adjustment
      [parkDateAdj, descProfDateAdj, ascProfDateAdj, ...
         nearSurfDateAdj, inAirDateAdj, evAct, pumpAct, cycleTimeData] = adjust_clock_offset_prv_ir( ...
         parkDate, descProfDate, ascProfDate, nearSurfDate, inAirDate, ...
         evAct, pumpAct, ...
         cycleTimeData, g_decArgo_clockOffset);

      if (~isempty(g_decArgo_outputCsvFileId))
         
         % output CSV file
         
         % print float technical messages in CSV file
         print_tech_data_in_csv_file_224(tabTech1, tabTech2, deepCycleFlag);
         
         % print dated data in CSV file
         print_dates_in_csv_file_221_to_225( ...
            cycleTimeData, ...
            descProfDate, descProfDateAdj, descProfPres, ...
            parkDate, parkDateAdj, parkPres, ...
            ascProfDate, ascProfDateAdj, ascProfPres, ...
            nearSurfDate, nearSurfDateAdj, nearSurfPres, ...
            inAirDate, inAirDateAdj, inAirPres, ...
            evAct, pumpAct);
         
         % print descending profile in CSV file
         print_descending_profile_in_csv_file_224( ...
            descProfDate, descProfDateAdj, ...
            descProfPres, descProfTemp, descProfSal, descProfTempCndc, ...
            [], [], [], []);
         
         % print drift measurements in CSV file
         print_drift_measurements_in_csv_file_224( ...
            parkDate, parkDateAdj, parkTransDate, ...
            parkPres, parkTemp, parkSal, parkTempCndc, ...
            [], [], [], []);

         % print ascending profile in CSV file
         print_ascending_profile_in_csv_file_224( ...
            ascProfDate, ascProfDateAdj, ...
            ascProfPres, ascProfTemp, ascProfSal, ascProfTempCndc, ...
            [], [], [], []);

         % print "near surface" and "in air" measurements in CSV file
         print_in_air_meas_in_csv_file_224( ...
            nearSurfDate, nearSurfDateAdj, nearSurfTransDate, ...
            nearSurfPres, nearSurfTemp, nearSurfSal, nearSurfTempCndc, ...
            [], [], [], [], ...
            inAirDate, inAirDateAdj, inAirTransDate, ...
            inAirPres, inAirTemp, inAirSal, inAirTempCndc, ...
            [], [], [], []);
         
         % print EV and pump data in CSV file
         print_hydraulic_data_in_csv_file_221_222_223_225(evAct, pumpAct);

         % print float parameters in CSV file
         print_float_prog_param_in_csv_file_224(floatParam1, floatParam2);
         
      else
         
         % output NetCDF files
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % PROF NetCDF file
         
         % process profile data for PROF NetCDF file
         tabProfiles = [];
         if (~isempty(dataCTDRbr))
            
            [tabProfiles] = process_profiles_224( ...
               descProfDate, descProfDateAdj, ...
               descProfPres, descProfTemp, descProfSal, descProfTempCndc, ...
               [], [], [], [], ...
               ascProfDate, ascProfDateAdj, ...
               ascProfPres, ascProfTemp, ascProfSal, ascProfTempCndc, ...
               [], [], [], [], ...
               g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
               cycleTimeData, ...
               tabTech2, a_decoderId);

            % add the vertical sampling scheme from configuration
            % information
            [tabProfiles] = add_vertical_sampling_scheme_ir_sbd(tabProfiles, a_decoderId);
            
            print = 0;
            if (print == 1)
               if (~isempty(tabProfiles))
                  fprintf('DEC_INFO: Float #%d Cycle #%d: %d profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum, length(tabProfiles));
                  for idP = 1:length(tabProfiles)
                     prof = tabProfiles(idP);
                     paramList = prof.paramList;
                     paramList = sprintf('%s ', paramList.name);
                     profLength = size(prof.data, 1);
                     fprintf('   ->%2d: dir=%c length=%d param=(%s)\n', ...
                        idP, prof.direction, ...
                        profLength, paramList(1:end-1));
                  end
               else
                  fprintf('DEC_INFO: Float #%d Cycle #%d: No profiles for NetCDF file\n', ...
                     g_decArgo_floatNum, g_decArgo_cycleNum);
               end
            end
            
            tabBuffProfiles = [tabBuffProfiles tabProfiles];
         end
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TRAJ NetCDF file
                  
         % process trajectory data for TRAJ NetCDF file
         [tabTrajNMeas, tabTrajNCycle, tabTechNMeas] = process_trajectory_data_224( ...
            g_decArgo_cycleNum, deepCycleFlag, ...
            g_decArgo_gpsData, g_decArgo_iridiumMailData, ...
            cycleTimeData, ...
            tabTech1, tabTech2, ...
            tabProfiles, ...
            parkDate, parkTransDate, ...
            parkPres, parkTemp, parkSal, parkTempCndc, ...
            [], [], [], [], ...
            nearSurfDate, nearSurfTransDate, ...
            nearSurfPres, nearSurfTemp, nearSurfSal, nearSurfTempCndc, ...
            [], [], [], [], ...
            inAirDate, inAirTransDate, ...
            inAirPres, inAirTemp, inAirSal, inAirTempCndc, ...
            [], [], [], [], ...
            evAct, pumpAct);

         % sort trajectory data structures according to the predefined
         % measurement code order
         [tabTrajNMeas] = sort_trajectory_data(tabTrajNMeas, a_decoderId);
         
         tabBuffTrajNMeas = [tabBuffTrajNMeas tabTrajNMeas];
         tabBuffTrajNCycle = [tabBuffTrajNCycle tabTrajNCycle];
         
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % TECH NetCDF file
         
         % store information on received Iridium packet types
         if (deepCycleFlag == 1)
            store_received_packet_type_info_for_nc(a_decoderId);
         end
         
         % store NetCDF technical data
         store_tech1_data_for_nc_222_to_225(tabTech1, deepCycleFlag);
         store_tech2_data_for_nc_224(tabTech2, deepCycleFlag);
         
         % store additional technical decoding information (for TECH_AUX
         % file)
         store_misc_tech_data_for_nc_212_214_216_to_218_222_to_225(a_decodedDataTab, a_decoderId);
         
         tabBuffNcTechIndex = [tabBuffNcTechIndex; g_decArgo_outputNcParamIndex];
         tabBuffNcTechVal = [tabBuffNcTechVal g_decArgo_outputNcParamValue];
         tabBuffTechNMeas = [tabBuffTechNMeas tabTechNMeas];
         
         g_decArgo_outputNcParamIndex = [];
         g_decArgo_outputNcParamValue = [];
         
      end
      
   otherwise
      fprintf('WARNING: Float #%d: Nothing implemented yet in process_decoded_data for decoderId #%d\n', ...
         g_decArgo_floatNum, ...
         a_decoderId);
end

% output parameters
if (isempty(g_decArgo_outputCsvFileId))
   if (~isempty(tabBuffProfiles))
      o_tabProfiles = [o_tabProfiles tabBuffProfiles];
   end
   if (~isempty(tabBuffTrajNMeas))
      o_tabTrajNMeas = [o_tabTrajNMeas tabBuffTrajNMeas];
   end
   if (~isempty(tabBuffTrajNCycle))
      o_tabTrajNCycle = [o_tabTrajNCycle tabBuffTrajNCycle];
   end
   if (~isempty(tabBuffNcTechIndex))
      o_tabNcTechIndex = [o_tabNcTechIndex; tabBuffNcTechIndex];
   end
   if (~isempty(tabBuffNcTechVal))
      o_tabNcTechVal = [o_tabNcTechVal; tabBuffNcTechVal'];
   end
   if (~isempty(tabBuffTechNMeas))
      o_tabTechNMeas = [o_tabTechNMeas tabBuffTechNMeas];
   end
end

return
