clear all;

% update SST
sst = ncread('cplFlux','SST');
uoce = ncread('cplFlux','UOCE');
voce = ncread('cplFlux','VOCE');
wavehs = ncread('cplFlux','WAVEHS');
waveml = ncread('cplFlux','WAVEML');
wavetaux = ncread('cplFlux','WAVETAUX');
wavetauy = ncread('cplFlux','WAVETAUY');
wavemask = ncread('cplFlux','WAVEMASK');

[nx,ny,nz] = size(sst);
sst_save = sst;
uoce_save = uoce;
voce_save = voce;
wavehs_save = wavehs;
waveml_save = waveml;
wavetaux_save = wavetaux;
wavetauy_save = wavetauy;
wavemask_save = wavemask;

for k = 1:nz-1
  sst(:,:,k) = sst_save(:,:,k+1);
  uoce(:,:,k) = uoce_save(:,:,k+1);
  voce(:,:,k) = voce_save(:,:,k+1);
  wavehs(:,:,k) = wavehs_save(:,:,k+1);
  waveml(:,:,k) = waveml_save(:,:,k+1);
  wavetaux(:,:,k) = wavetaux_save(:,:,k+1);
  wavetauy(:,:,k) = wavetauy_save(:,:,k+1);
  wavemask(:,:,k) = wavemask_save(:,:,k+1);
end

ncwrite('cplFlux','SST',sst);
ncwrite('cplFlux','UOCE',uoce);
ncwrite('cplFlux','VOCE',voce);
ncwrite('cplFlux','WAVEHS',wavehs);
ncwrite('cplFlux','WAVEML',waveml);
ncwrite('cplFlux','WAVETAUX',wavetaux);
ncwrite('cplFlux','WAVETAUY',wavetauy);
ncwrite('cplFlux','WAVEMASK',wavemask);
