% Compute mean and standard deviation of December 2011 surface Theta and KPPhbl.
% Extract surface Theta and KPPhbl at Argo locations during December 2011.

% initialize
cd ~dmenemen/llc_4320/regions/Argo

% get llc4320 grid
nx=4320;
prec='real*4';
gdir='~dmenemen/llc_4320/grid/';

% iterate over all model time steps to extract fields
N=0;
meanSST=zeros(nx,nx*3,'single');
meanHBL=zeros(nx,nx*3,'single');
pin='~dmenemen/llc_4320/MITgcm/run/';
for ts=283536:144:390528
    N=N+1;

    % extract mean, mean squared, and Argo profile SST
    fin=[pin 'Theta.' myint2str(ts,10) '.data'];
    disp(fin)
    fld=read_llc_fkij(fin,nx,1,1,1:nx,1:(nx*3),prec);
    meanSST=meanSST+fld;

    % extract mean, mean squared, and Argo profile SST
    fin=[pin 'KPPhbl.' myint2str(ts,10) '.data'];
    disp(fin)
    fld=read_llc_fkij(fin,nx,1,1,1:nx,1:(nx*3),prec);
    meanHBL=meanHBL+fld;
end

meanSST=meanSST/N;
meanHBL=meanHBL/N;
clear I N Y a* fi* fld g* i* nx pi* pre* tm* ts
save mean
