diff --git a/tsg_util/headerForm.m b/tsg_util/headerForm.m
index ee139d5c0f00d686a570b664e3cd688136aeb7a3..67feda4d645d351f6b33687c24a732ce23b0d191 100644
--- a/tsg_util/headerForm.m
+++ b/tsg_util/headerForm.m
@@ -197,14 +197,18 @@ add_variables;
 
 % additinnal coefficient variable here
 % ------------------------------------
-if ~isempty(tsg.SSJT_CALCOEF)
-  add_coefficients;
-end
+%if ~isempty(tsg.SSJT_CALCOEF)
+add_coefficients;
+%end
 
 % set a callback to PLATFORM_NAME uicontrol
 % -----------------------------------------
 set(findobj('Tag', 'PLATFORM_NAME'), 'Callback', @updateForm);
 
+% set a callback to check date
+% ----------------------------
+set(findobj('-regexp', 'Tag', 'CALCOEF_DATE'), 'Callback', @editCallback);
+
 % CONTINUE PUSH BUTTON
 % --------------------
 % The Continue (valid)  button
@@ -249,6 +253,18 @@ uiwait(hHeaderFig);
 
 %% Nested callback
 
+% -----------------------------------------------------------------------
+% check if date format is valid, if not beep and set empty string 
+% -----------------------------------------------------------------------
+  function editCallback(obj, event)
+    value = get(obj, 'string');
+    match = regexp( value, '(\d{2})/(\d{2})/(\d{4})', 'tokens');
+    if isempty(match)
+      beep;
+      set(obj, 'string', '');
+    end
+  end
+
 % -----------------------------------------------------------------------
 % Continue action, get uicontrol fields and populate tsg structure
 % -----------------------------------------------------------------------
@@ -346,10 +362,14 @@ uiwait(hHeaderFig);
           s = get(data.(strcat(var,'_',key)), 'string');
           %tsg.(var)(i) = single(str2double(get(data.(strcat(var,'_',key)), 'string')));
 
-          if strcmpi(key, 'DATE')
-            tsg.(var)(ii) = single(datenumToJulian(datenum(s, 'dd/mm/yyyy')));
+          if strcmp(s, '')
+            tsg.(var)(ii) = NaN;
           else
-            tsg.(var)(ii) = single(str2double(s));
+            if strcmpi(key, 'DATE')
+              tsg.(var)(ii) = single(datenumToJulian(datenum(s, 'dd/mm/yyyy')));
+            else
+              tsg.(var)(ii) = single(str2double(s));
+            end
           end
           %p_i.(key) = tsg.(key);
         end
@@ -576,13 +596,13 @@ uiwait(hHeaderFig);
       % ------------------------------
       var = char(acv);
 
-      % check before use, if variable has the right fixed dimensions
-      % if not, write fillValue (NaN or char filled with blanks)
+      % check before use, if variable has the right vertical dimensions
+      % if not, write fillValue: NaN or char filled with blanks
       % ------------------------------------------------------------
       match = regexp(var, '\w+_(\w+)', 'tokens');
       for ii=numel(tsg.(var))+1:tsg.dim.(char(match{1}))
         tsg.(var)(ii) = NaN;
-        tsg.([var '_CONV'])(ii,:) = padding('', tsg.dim.CALCOEF_CONV);
+        tsg.([var '_CONV'])(ii,:) = padding('', tsg.dim.COEF_CONV_SIZE);
       end
 
       % loop for each value of coefficient variable
@@ -593,13 +613,15 @@ uiwait(hHeaderFig);
 
         % if fillValue, don't display uicontrol
         % -------------------------------------
-        if strcmp(cle, padding('', tsg.dim.CALCOEF_CONV))
+        if strcmp(cle, padding('', tsg.dim.COEF_CONV_SIZE))
           continue
         end
 
         % if key is date, use special format, not real
         % --------------------------------------------
-        if strcmpi(cle, padding('DATE', tsg.dim.CALCOEF_CONV))
+        if isnan(tsg.(var)(ii))
+          value = '';
+        elseif strcmpi(cle, padding('DATE', tsg.dim.COEF_CONV_SIZE))
           value = datestr(julianToDatenum(tsg.(var)(ii)), 'dd/mm/YYYY');
         else
           value = num2str(tsg.(var)(ii));
diff --git a/tsg_util/preferencesForm.m b/tsg_util/preferencesForm.m
index 6661bbfd316e3535a2e5566a230e95fd6908c01e..5cb8a66116c45950e46ac4003e9a83a8d7c175dd 100644
--- a/tsg_util/preferencesForm.m
+++ b/tsg_util/preferencesForm.m
@@ -152,6 +152,38 @@ if bottom < .1
   left = left + inc_x;
 end
 
+% display connected line text
+% -------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', ...
+  'Style', 'Text', ...
+  'Fontsize', tsg.fontSize-1, ...
+  'HorizontalAlignment', 'left', ...
+  'Position',[left, bottom, length, height], ...
+  'TooltipString', 'select coefficients type', ...
+  'String', 'Coefficients type');
+
+% display connected line uicontrol
+% --------------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', ...
+  'BackgroundColor', 'w', ...
+  'Style', 'popupmenu', ...
+  'Fontsize', tsg.fontSize-2, ...
+  'HorizontalAlignment', 'right', ...
+  'Position', [left + length, bottom, length, height], ...
+  'String', tsg.preference.coeff_type_string , ...
+  'Value', tsg.preference.coeff_type_value , ...
+  'Tag', 'PREFERENCES_COEFF_TYPE');
+
+bottom = bottom - inc_y - height;
+if bottom < .1
+  bottom = 0.95;
+  left = left + inc_x;
+end
+
 % CONTINUE PUSH BUTTON
 % --------------------
 % The Continue (valid)  button
@@ -214,6 +246,8 @@ uiwait(hPreferencesFig);
                       get(prefs.PREFERENCES_LEVITUS_DEPTH, 'value');
     tsg.preference.plot_connected_value = ...
                       get(prefs.PREFERENCES_PLOT_CONNECTED_LINE, 'value');
+    tsg.preference.coeff_type_value = ...
+                      get(prefs.PREFERENCES_COEFF_TYPE, 'value');
     
     % Save tsg structure
     % ------------------
diff --git a/tsg_util/tsg_initialisation.m b/tsg_util/tsg_initialisation.m
index 1539bc10f7f895287ceb27536b66bd0c16109466..af56245fe97424dee846641a33f5569a818c8736 100644
--- a/tsg_util/tsg_initialisation.m
+++ b/tsg_util/tsg_initialisation.m
@@ -26,7 +26,7 @@ set( hMainFig, 'WindowButtonMotionFcn', []);
 % Get the tsg struct from the application GUI
 % -------------------------------------------
 tsg = getappdata( hMainFig, 'tsg_data');
-    
+
 % init empty tsg structure
 % ------------------------
 if exist('tsg', 'var') && isfield( tsg, 'preference')
@@ -43,7 +43,7 @@ end
 
 % define netcdf dimensions
 % ------------------------
-tsg.dim.STRING256 = 256;   
+tsg.dim.STRING256 = 256;
 tsg.dim.STRING14  = 14;
 tsg.dim.STRING8   = 8;
 tsg.dim.STRING4   = 4;
@@ -51,9 +51,9 @@ tsg.dim.N1        = 1;
 tsg.dim.CALCOEF   = 7;
 tsg.dim.LINCOEF   = 2;
 
-% variable tsg.CALCOEF_CONV is cahr array of (CALCOEF x STRING8)
+% variable tsg.CALCOEF_CONV is char array of (CALCOEF x STRING8)
 % --------------------------------------------------------------
-tsg.dim.CALCOEF_CONV = tsg.dim.STRING8;
+tsg.dim.COEF_CONV_SIZE = tsg.dim.STRING8;
 
 % date of reference for julian days, is 1st january 1950
 % ------------------------------------------------------
@@ -76,7 +76,7 @@ tsg.levitus.version = 'none';
 tsg.levitus.time    = 1;
 
 % -------------------------------------------------------------------------
-%%              file fields 
+%%              file fields
 % -------------------------------------------------------------------------
 tsg.file.pathstr = [];
 tsg.file.name    = [];
@@ -101,7 +101,7 @@ tsg.report.extfile  = '';  % Name of the External sample file
 tsg.report.nodate   =  0;  % Records deleted because they have no date
 tsg.report.sortdate =  0;  % Records deleted because date is not increasing
 tsg.report.badvelocity = 0;  % Records deleted because of bad velocity
-                             % (> 50 knots - test in shipVelocity)
+% (> 50 knots - test in shipVelocity)
 
 % -------------------------------------------------------------------------
 %%              Structure used to merge WS and EXT sample
@@ -119,28 +119,28 @@ tsg.report.badvelocity = 0;  % Records deleted because of bad velocity
 % tsg.SSJT_SPL      = [];
 % tsg.SSJT_SPL_QC   = [];
 % tsg.SSJT_SPL_TYPE = [];
-% 
+%
 % -------------------------------------------------------------------------
 %%              Constants for the quality control procedure
 % -------------------------------------------------------------------------
 
 % Quality flags reference table, see GOSUD, DATA FORMAT TSG V1.4, table 4
 % -----------------------------------------------------------------------
-%  Code      Meaning                        
+%  Code      Meaning
 %
 %  0         No QC was performed
-%  1         Good data                     
-%  2         Probably good data             
-%  3         Bad data that are potentially correctable          
-%  4         Bad data                  
-%  5         Value changed                   
-%  6         Data acquired in harbour                             
-%  7         Not used                        
-%  8         Interpolated value                              
-%  9         Missing value                              
-
-% Quality definition, we use a hashtable with a definition file 
-% located in @tsg_nc/tsg_quality.csv, 
+%  1         Good data
+%  2         Probably good data
+%  3         Bad data that are potentially correctable
+%  4         Bad data
+%  5         Value changed
+%  6         Data acquired in harbour
+%  7         Not used
+%  8         Interpolated value
+%  9         Missing value
+
+% Quality definition, we use a hashtable with a definition file
+% located in @tsg_nc/tsg_quality.csv,
 % use this file if you want add or modify quality context menu
 % -------------------------------------------------------------
 tsg.qc.hash = tsg_nc('tsg_quality.csv');
@@ -198,7 +198,6 @@ nca             = tsg_nc('tsg_ncattr.csv');
 % dimensions
 % ----------
 tsg.DAYD                  = [];
-%tsg.DAYD_WS               = [];
 tsg.DAYD_EXT              = [];
 
 % initialise tsg structure from tsg_nc objects
@@ -220,10 +219,10 @@ end
 % ---------------
 tsg.FORMAT_VERSION        =  NETCDF_FORMAT_VERSION;
 tsg.DATE_CREATION         =  [date(1:8) date(10:15)];
-tsg.DATE_UPDATE           =  tsg.DATE_CREATION; 
+tsg.DATE_UPDATE           =  tsg.DATE_CREATION;
 tsg.REFERENCE_DATE_TIME   =  REFERENCE_DATE_TIME;
 
-% Save tsg structure 
+% Save tsg structure
 % ------------------
 setappdata( hMainFig, 'tsg_data', tsg);
 
diff --git a/tsg_util/tsg_preferences.m b/tsg_util/tsg_preferences.m
index 66be881ff5251f91470ff99169b7810d4c3b5bb0..e1fbd8774b6296091cb1dc1fc4896438b4f567c0 100644
--- a/tsg_util/tsg_preferences.m
+++ b/tsg_util/tsg_preferences.m
@@ -138,6 +138,8 @@ end
     preference.ship_speed            = 1;
     preference.plot_connected_string = {'none', '-', '--', ':', '-.'};
     preference.plot_connected_value  = 1;  % 0, line not connected
+    preference.coeff_type_string     = {'a,b,c,d,f0', 'g,h,i,k,m'};
+    preference.coeff_type_value      = 2;
 
     % save preference struct to 'prefdir.mat' file
     % ---------------------------------------------
diff --git a/tsg_util/updateTsgStruct.m b/tsg_util/updateTsgStruct.m
index 318ecfed71cee3d5786d3fe9381049b2dc5f83b9..a6b945207061337242ed5afbbfd549deec18ae4d 100644
--- a/tsg_util/updateTsgStruct.m
+++ b/tsg_util/updateTsgStruct.m
@@ -86,21 +86,53 @@ for i = 1: length(names)
   end
 end
 
-% Initialise  'variables_LINCOEF'
-% -------------------------------
-if isempty(tsg.SSJT_LINCOEF)
-  tsg.SSJT_LINCOEF(1) = 1;
-  tsg.SSJT_LINCOEF(2) = 0;
-end
-if isempty(tsg.CNDC_LINCOEF)
-  tsg.CNDC_LINCOEF(1) = 1;
-  tsg.CNDC_LINCOEF(2) = 0;
+% initialise empty coefficients variables with type defined with preference
+% -------------------------------------------------------------------------
+coeff_type = {{'DATE','A','B','C','D','F0',''},{'DATE','A','B','C','D','M','CPCOR'},...
+  {'DATE','A','B','C','D','F0',''}; ...
+  {'DATE','G','H','I','J','F0',''},{'DATE','G','H','I','J','CTCOR','CPCOR'},...
+  {'DATE','G','H','I','J','F0',''}};
+lin_type = {'offset','slope'};
+lin_val  = [0,1];
+
+var = {'SSJT_CALCOEF', 'CNDC_CALCOEF', 'SSTP_CALCOEF'};
+
+pref = tsg.preference.coeff_type_value;
+
+for i = 1:numel(var)
+  for j = 1:tsg.dim.CALCOEF
+    tsg.(var{i})(j) = NaN;
+    tsg.([var{i} '_CONV']) = ...
+      [tsg.([var{i} '_CONV']); padding(coeff_type{pref,i}{j}, tsg.dim.COEF_CONV_SIZE)];
+  end
 end
-if isempty(tsg.SSTP_LINCOEF)
-  tsg.SSTP_LINCOEF(1) = 1;
-  tsg.SSTP_LINCOEF(2) = 0;
+
+var ={'SSJT_LINCOEF', 'CNDC_LINCOEF', 'SSTP_LINCOEF'};
+
+for i = 1:numel(var)
+  for j = 1:tsg.dim.LINCOEF
+    tsg.(var{i})(j) = lin_val(j);
+    tsg.([var{i} '_CONV']) = ...
+      [tsg.([var{i} '_CONV']); padding(lin_type{j}, tsg.dim.COEF_CONV_SIZE)];
+  end
 end
 
+% Initialise  'variables_LINCOEF'
+% in tsg_initialisation now
+% -------------------------------
+% if isempty(tsg.SSJT_LINCOEF)
+%   tsg.SSJT_LINCOEF(1) = 1;
+%   tsg.SSJT_LINCOEF(2) = 0;
+% end
+% if isempty(tsg.CNDC_LINCOEF)
+%   tsg.CNDC_LINCOEF(1) = 1;
+%   tsg.CNDC_LINCOEF(2) = 0;
+% end
+% if isempty(tsg.SSTP_LINCOEF)
+%   tsg.SSTP_LINCOEF(1) = 1;
+%   tsg.SSTP_LINCOEF(2) = 0;
+% end
+
 % Save tsg structure
 % ------------------
 setappdata( hMainFig, 'tsg_data', tsg);
diff --git a/tsgqc.m b/tsgqc.m
index 67165bb1f7f7c9342d09cedd3881427ef0ac08d7..269a37e2d1892a87b3708aeb8297a5eb40e2c57d 100644
--- a/tsgqc.m
+++ b/tsgqc.m
@@ -36,8 +36,8 @@ global NETCDF_FORMAT_VERSION
 % version number, may be used to initialize some files when it change
 % 0.90x -> 1.0RCx
 % -------------------------------------------------------------------
-VERSION = 0.9051;  % -> 1.0RC5
-CHAR_VERSION = '1.0RC5_1';
+VERSION = 0.9053;  % -> 1.0RC5
+CHAR_VERSION = '1.0RC5_3';
 
 % netcdf file version, see DATA FORMAT TSG document:
 % CORTSG_format_gosud_1.5.doc
@@ -3148,46 +3148,61 @@ hrbInterpCancel = uicontrol( ...
 % -----------------------------------------------------------------
   function QuitMenuCallback(hObject, eventdata)
 
-    % save config mat file in prefdir
-    % -------------------------------
-    config_file = [prefdir, filesep, tsgqcname, '.mat'];
+    % in case of bad initialisation, the user could close the windows
+    % ---------------------------------------------------------------
+    try
+      
+      % save config mat file in prefdir
+      % -------------------------------
+      config_file = [prefdir, filesep, tsgqcname, '.mat'];
 
-    % save preference mat file
-    % ------------------------
-    preference = tsg.preference;
-    save( config_file, 'preference');
+      % save preference mat file
+      % ------------------------
+      if exist('tsg', 'var') && isfield( tsg, 'preference')
+        preference = tsg.preference;
+        save( config_file, 'preference');
+      end
 
-    % If the data have been modified and not save, the program
-    % ask to save the data
-    % --------------------------------------------------------
-    if  strcmp( get( hSaveMenu, 'UserData' ), 'on')
-      selection = ...
-        questdlg('The file has been modified.  Do you want to save it ?',...
-        'Save before Quit?',...
-        'Yes', 'No', 'Yes');
+      % If the data have been modified and not save, the program
+      % ask to save the data
+      % --------------------------------------------------------
+      if  strcmp( get( hSaveMenu, 'UserData' ), 'on')
+        selection = ...
+          questdlg('The file has been modified.  Do you want to save it ?',...
+          'Save before Quit?',...
+          'Yes', 'No', 'Yes');
 
-      if strcmp(selection, 'Yes')
+        if strcmp(selection, 'Yes')
 
-        % call File/Save Menu Callback before before quit
-        % -----------------------------------------------
-        SaveMenuCallback;
+          % call File/Save Menu Callback before before quit
+          % -----------------------------------------------
+          SaveMenuCallback;
 
-      end
+        end
 
-      % quit program
-      % ------------
-      quitProgram(DEFAULT_PATH_FILE, hMainFig, hMapFig);
+        % quit program
+        % ------------
+        quitProgram(DEFAULT_PATH_FILE, hMainFig, hMapFig);
 
-    else
-      selection = ...
-        questdlg(['Quit ' get(hMainFig, 'Name') '?'],...
-        ['Quit ' get(hMainFig, 'Name') '?'],...
-        'Yes', 'No', 'Yes');
-      if strcmp(selection, 'No')
-        return;
       else
-        quitProgram(DEFAULT_PATH_FILE, hMainFig, hMapFig);
+        selection = ...
+          questdlg(['Quit ' get(hMainFig, 'Name') '?'],...
+          ['Quit ' get(hMainFig, 'Name') '?'],...
+          'Yes', 'No', 'Yes');
+        if strcmp(selection, 'No')
+          return;
+        else
+          quitProgram(DEFAULT_PATH_FILE, hMainFig, hMapFig);
+        end
       end
+
+    % catch error during close windows
+    % --------------------------------
+    catch
+      % display message to console and quit program
+      % -------------------------------------------
+      fprintf('abnormal program termination during close user request\n');
+      quitProgram(DEFAULT_PATH_FILE, hMainFig);
     end
 
   end