| 1 | % | % | 
| 2 | % [RHO,LON,LAT,DPT] = compute_density(SNAPSHOT) | % [RHO] = compute_density(SNAPSHOT) | 
| 3 | % | % | 
| 4 | % For a time snapshot, this program computes the | % For a time snapshot, this program computes the | 
| 5 | % 3D density from potential temperature and salinity fields. | % 3D density from potential temperature and salinity fields. | 
| 21 | % | % | 
| 22 |  |  | 
| 23 |  |  | 
| 24 | function compute_density(snapshot) | function varargout = compute_density(snapshot) | 
| 25 |  |  | 
| 26 |  |  | 
| 27 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 38 |  |  | 
| 39 | %% Path and extension to find them: | %% Path and extension to find them: | 
| 40 | pathname = strcat('netcdf-files',sla,snapshot); | pathname = strcat('netcdf-files',sla,snapshot); | 
| 41 |  | %pathname = '.'; | 
| 42 | ext      = strcat('.',netcdf_suff); | ext      = strcat('.',netcdf_suff); | 
| 43 |  |  | 
| 44 | %% Load netcdf files: | %% Load netcdf files: | 
| 160 |  |  | 
| 161 |  |  | 
| 162 | % Output: | % Output: | 
| 163 |  | output = struct('RHO',RHO,'dpt',dpt,'lat',lat,'lon',lon); | 
| 164 | switch nargout | switch nargout | 
| 165 | case 1 | case 1 | 
| 166 | varargout(1) = RHO; | varargout(1) = {output}; | 
|  | case 2 |  | 
|  | varargout(1) = RHO; |  | 
|  | varargout(2) = lon; |  | 
|  | case 3 |  | 
|  | varargout(1) = RHO; |  | 
|  | varargout(2) = lon; |  | 
|  | varargout(3) = lat; |  | 
|  | case 4 |  | 
|  | varargout(1) = RHO; |  | 
|  | varargout(2) = lon; |  | 
|  | varargout(3) = lat; |  | 
|  | varargout(4) = dpt; |  | 
| 167 | end | end |