1 |
% |
% |
2 |
% [] = compute_alpha(SNAPSHOT) |
% [ALPHA] = compute_alpha(SNAPSHOT) |
3 |
% |
% |
4 |
% This function computes the thermal expansion coefficient from |
% This function computes the thermal expansion coefficient from |
5 |
% files of potential temperature THETA and salinity anomaly |
% files of potential temperature THETA and salinity anomaly |
6 |
% SALTanom. |
% SALTanom. |
7 |
|
% SALTanom is by default a salinity anomaly vs 35PSU. |
8 |
|
% If not, (is absolute value) set the global variable is_SALTanom to 0 |
9 |
% |
% |
10 |
% Files name are: |
% Files name are: |
11 |
% INPUT: |
% INPUT: |
42 |
ncS = netcdf(ferfile,'nowrite'); |
ncS = netcdf(ferfile,'nowrite'); |
43 |
[Slon Slat Sdpt] = coordfromnc(ncS); % but normaly is the same grid as T |
[Slon Slat Sdpt] = coordfromnc(ncS); % but normaly is the same grid as T |
44 |
|
|
45 |
|
% Salinity field ref; |
46 |
|
global is_SALTanom |
47 |
|
if exist('is_SALTanom') |
48 |
|
if is_SALTanom == 1 |
49 |
|
bS = 35; |
50 |
|
else |
51 |
|
bS = 0; |
52 |
|
end |
53 |
|
end |
54 |
|
|
55 |
|
|
56 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
71 |
for iz = 1 : nz |
for iz = 1 : nz |
72 |
if toshow,disp(strcat('Compute alpha for level:',num2str(iz),'/',num2str(nz)));end |
if toshow,disp(strcat('Compute alpha for level:',num2str(iz),'/',num2str(nz)));end |
73 |
TEMP = ncT{4}(iz,:,:); |
TEMP = ncT{4}(iz,:,:); |
74 |
SALT = ncS{4}(iz,:,:) + 35; |
SALT = ncS{4}(iz,:,:) + bS; |
75 |
PRES = (0.09998*9.81*Tdpt(iz))*ones(ny,nx); |
PRES = (0.09998*9.81*Tdpt(iz))*ones(ny,nx); |
76 |
ALPHA(iz,:,:) = sw_alpha(SALT,TEMP,PRES,'ptmp'); |
ALPHA(iz,:,:) = sw_alpha(SALT,TEMP,PRES,'ptmp'); |
77 |
end %for iz |
end %for iz |
132 |
nc{ncid}(:,:,:) = ALPHA; |
nc{ncid}(:,:,:) = ALPHA; |
133 |
|
|
134 |
nc=close(nc); |
nc=close(nc); |
135 |
|
close(ncS); |
136 |
|
close(ncT); |
137 |
|
|
138 |
|
% Output: |
139 |
|
output = struct('ALPHA',ALPHA,'dpt',Tdpt,'lat',Tlat,'lon',Tlon); |
140 |
|
switch nargout |
141 |
|
case 1 |
142 |
|
varargout(1) = {output}; |
143 |
|
end |