| 1 |
% |
% |
| 2 |
% [] = compute_alpha(SNAPSHOT) |
% [ALPHA,LON,LAT,DPT] = 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 |
| 134 |
nc=close(nc); |
nc=close(nc); |
| 135 |
|
|
| 136 |
|
|
| 137 |
|
% Output: |
| 138 |
|
switch nargout |
| 139 |
|
case 1 |
| 140 |
|
varargout(1) = ALPHA; |
| 141 |
|
case 2 |
| 142 |
|
varargout(1) = ALPHA; |
| 143 |
|
varargout(2) = Tlon; |
| 144 |
|
case 3 |
| 145 |
|
varargout(1) = ALPHA; |
| 146 |
|
varargout(2) = Tlon; |
| 147 |
|
varargout(3) = Tlat; |
| 148 |
|
case 4 |
| 149 |
|
varargout(1) = ALPHA; |
| 150 |
|
varargout(2) = Tlon; |
| 151 |
|
varargout(3) = Tlat; |
| 152 |
|
varargout(4) = Tdpt; |
| 153 |
|
end |