/[MITgcm]/MITgcm_contrib/gmaze_pv/A_compute_potential_density.m
ViewVC logotype

Diff of /MITgcm_contrib/gmaze_pv/A_compute_potential_density.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1 by gmaze, Fri Jun 16 21:12:20 2006 UTC revision 1.5 by gmaze, Thu Feb 1 17:02:02 2007 UTC
# Line 1  Line 1 
1  %  %
2  % [] = A_COMPUTE_POTENTIAL_DENSITY(SNAPSHOT)  % [ST] = A_compute_potential_density(SNAPSHOT)
3  %  %
4  % For a time snapshot, this program computes the  % For a time snapshot, this program computes the
5  % 3D potential density from potential temperature and salinity.  % 3D potential density from potential temperature and salinity.
6  % THETA and SALTanom are supposed to be defined on the same  % THETA and SALTanom are supposed to be defined on the same
7  % domain and grid.  % domain and grid.
8    % SALTanom is by default a salinity anomaly vs 35.
9    % If not, (is absolute value) set the global variable is_SALTanom to 0
10    %
11    % Files names are:
12    % INPUT:
13    % ./netcdf-files/<SNAPSHOT>/<netcdf_THETA>.<netcdf_domain>.<netcdf_suff>
14    % ./netcdf-files/<SNAPSHOT>/<netcdf_SALTanom>.<netcdf_domain>.<netcdf_suff>
15    % OUPUT:
16    % ./netcdf-files/<SNAPSHOT>/SIGMATHETA.<netcdf_domain>.<netcdf_suff>
17  %  %
18  % 06/07/2006  % 06/07/2006
19  % gmaze@mit.edu  % gmaze@mit.edu
20  %  %
21    
22        
23  function A_compute_potential_density(snapshot)  function varargout = A_compute_potential_density(snapshot)
24    
25    
26  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Line 38  ferfile = strcat(pathname,sla,filSALTa,e Line 47  ferfile = strcat(pathname,sla,filSALTa,e
47  ncSALTa = netcdf(ferfile,'nowrite');  ncSALTa = netcdf(ferfile,'nowrite');
48  SALTavariables = var(ncSALTa);  SALTavariables = var(ncSALTa);
49    
50    global is_SALTanom
51    if exist('is_SALTanom')
52      if is_SALTanom == 1
53        bS = 35;
54      else
55        bS = 0;
56      end
57    end
58    
59  %% Gridding:  %% Gridding:
60  % Don't care about the grid here !  % Don't care about the grid here !
61  % SALTanom and THETA are normaly defined on the same grid  % SALTanom and THETA are normaly defined on the same grid
# Line 67  SIGMATHETA = zeros(nz,ny,nx); Line 85  SIGMATHETA = zeros(nz,ny,nx);
85  for iz = 1 : nz  for iz = 1 : nz
86    if toshow,disp(strcat('Compute potential density at level:',num2str(iz),'/',num2str(nz)));end    if toshow,disp(strcat('Compute potential density at level:',num2str(iz),'/',num2str(nz)));end
87        
88    S = SALTavariables{4}(iz,:,:) + 35; % Move the anom to an absolute field    S = SALTavariables{4}(iz,:,:) + bS; % Evantualy move the anom to an absolute field
89    T = THETAvariables{4}(iz,:,:);    T = THETAvariables{4}(iz,:,:);
90    SIGMATHETA(iz,:,:) = densjmd95(S,T,zeros(ny,nx)) - 1000;    SIGMATHETA(iz,:,:) = densjmd95(S,T,zeros(ny,nx)) - 1000;
91        
92    % Eventualy make a plot of the field:    % Eventualy make a plot of the field:
93    if 0    if 0 & iz==1
94      clf;pcolor(squeeze(SIGMATHETA(iz,:,:)));      clf;pcolor(squeeze(SIGMATHETA(iz,:,:)));
95      shading interp;caxis([10 40]);colorbar      shading interp;caxis([20 30]);colorbar
96      drawnow      drawnow
97      M(iz)=getframe; % To make a video      %M(iz)=getframe; % To make a video
98    end %if1    end %if1
99  end %for iz  end %for iz
100    
# Line 137  nc{ncid}.uniquename    = ncchar(uniquena Line 155  nc{ncid}.uniquename    = ncchar(uniquena
155  nc{ncid}(:,:,:)        = SIGMATHETA;  nc{ncid}(:,:,:)        = SIGMATHETA;
156    
157  nc=close(nc);  nc=close(nc);
158    close(ncTHETA);
159    close(ncSALTa);
160    
161    % Outputs:
162    output = struct('SIGMATHETA',SIGMATHETA,'dpt',dpt,'lat',lat,'lon',lon);
163    switch nargout
164     case 1
165      varargout(1) = {output};
166    end

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.22