From 7007b675bb277b06ec747867d03779853816c5bb Mon Sep 17 00:00:00 2001
From: Jacques Grelet <jacques.grelet@ird.fr>
Date: Tue, 1 Jun 2010 09:00:37 +0000
Subject: [PATCH] =?UTF-8?q?les=20variables=20POSITION=5FQC=20et=20var=5FAD?=
 =?UTF-8?q?JUSTED=5FQC=20n'=C3=A9taient=20pas=20initialisee=20a=20zero=20e?=
 =?UTF-8?q?t=20prenaient=20la=20valeur=20-127=20lors=20de=20la=20creation?=
 =?UTF-8?q?=20du=20fichier=20NetCDF,=20rajoute=20la=20commande=20sync=20da?=
 =?UTF-8?q?ns=20write=20a=20la=20fin=20de=20l'ecriture=20des=20variables?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 @netcdf_native/write.m     |  7 ++++++-
 tsg_util/castByteQC.m      |  2 +-
 tsg_util/updateTsgStruct.m | 17 +++++++++++++++--
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/@netcdf_native/write.m b/@netcdf_native/write.m
index 70829ae..53fd7ef 100644
--- a/@netcdf_native/write.m
+++ b/@netcdf_native/write.m
@@ -388,7 +388,7 @@ for i=1:numel(ncv_keys)
   % If a NetCDF variable has valid _FillValue attributes, then
   % the data is filled accordingly.
   % ----------------------------------------------------------
-  if self.autonan && isfield(s, 'FillValue_')
+  if self.autonan && isfield(s, 'FillValue_') && ~isempty(s.FillValue_)
     value(isnan(value)) = s.FillValue_;
   end
   
@@ -404,6 +404,11 @@ for i=1:numel(ncv_keys)
       'Cannot write netcdf file\n%s.', exception.message);  %#ok<CTPCT>
     
   end
+  
+  % synchronize netcdf file to disk
+  % -------------------------------
+  netcdf.sync(self.nc_id);
+  
 end % end for ncv variables loop
 
 % Close waitbar
diff --git a/tsg_util/castByteQC.m b/tsg_util/castByteQC.m
index 2389d32..a08ce7d 100644
--- a/tsg_util/castByteQC.m
+++ b/tsg_util/castByteQC.m
@@ -8,6 +8,6 @@ function [tabOut] = castByteQC( code, tabIn )
 % $Id$
 
 
- tabOut = int8(code) * int8( ones(size(tabIn) ));
+ tabOut = uint8(code) * uint8( ones(size(tabIn) ));
  
 end
diff --git a/tsg_util/updateTsgStruct.m b/tsg_util/updateTsgStruct.m
index 10297bf..6dbb73e 100644
--- a/tsg_util/updateTsgStruct.m
+++ b/tsg_util/updateTsgStruct.m
@@ -20,8 +20,8 @@ shipVelocity( hMainFig );
 % -------------------------------------
 tsg = getappdata( hMainFig, 'tsg_data');
 
-nPARA = 2;
-PARA  = ['SSPS'; 'SSJT'];
+nPARA = 3;
+PARA  = ['SSPS'; 'SSJT'; 'SSTP'];
 
 % Get NO_CONTROL and INTERPOLATED_VALUE codes
 % a modifier !!!!!!!!!!!!!
@@ -72,6 +72,7 @@ tsg.DATE_END   = [date(1:8) date(10:15)];
 for i = 1: nPARA
 
   para1 =  PARA(i,:);
+  
   if ~isempty( tsg.(para1) ) && isempty( tsg.([para1 '_QC']) )
 
     % If QC variables are emptied, fill them with NO_CONTROL code value
@@ -79,8 +80,20 @@ for i = 1: nPARA
     tsg.([para1 '_QC']) = castByteQC( NO_CONTROL, tsg.DAYD );
 
   end
+  
+  if ~isempty( tsg.(para1) ) && isempty( tsg.([para1 '_ADJUSTED_QC']) )
+
+    % If QC variables are emptied, fill them with NO_CONTROL code value
+    % -----------------------------------------------------------------
+    tsg.([para1 '_ADJUSTED_QC']) = castByteQC( NO_CONTROL, tsg.DAYD );
+
+  end
 end
 
+% initialize POSITION_QC
+% ----------------------
+tsg.('POSITION_ADJUSTED_QC') = castByteQC( NO_CONTROL, tsg.DAYD );
+
 % Empty variables filled with NaN
 % -------------------------------
 names = fieldnames( tsg );
-- 
GitLab