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

Annotation of /MITgcm_contrib/gmaze_pv/compute_MLD.m

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


Revision 1.1 - (hide annotations) (download)
Fri Oct 6 18:54:35 2006 UTC (18 years, 9 months ago) by gmaze
Branch: MAIN
update

1 gmaze 1.1 %
2     % [] = compute_MLD(SNAPSHOT)
3     %
4     % Here we compute the Mixed Layer Depth as:
5     % MLD = min depth for which : ST > ST(SSS,SST-0.8,p0)
6     %
7     % where:
8     % ST is potential density (kg/m3)
9     % SST the Sea Surface Temperature (oC)
10     % SSS the Sea Surface Salinity (PSU-35)
11     % p0 the Sea Level Pressure (mb)
12     % EKL is the Ekman layer depth (m)
13     %
14     % Files names are:
15     % INPUT:
16     % ./netcdf-files/<SNAPSHOT>/<netcdf_SIGMATHETA>.<netcdf_domain>.<netcdf_suff>
17     % ./netcdf-files/<SNAPSHOT>/<netcdf_THETA>.<netcdf_domain>.<netcdf_suff>
18     % ./netcdf-files/<SNAPSHOT>/<netcdf_SALTanom>.<netcdf_domain>.<netcdf_suff>
19     % OUTPUT
20     % ./netcdf-files/<SNAPSHOT>/<netcdf_MLD>.<netcdf_domain>.<netcdf_suff>
21     %
22     % with netcdf_* as global variables
23     % netcdf_MLD = 'MLD' by default
24     %
25     % Rq: This method leads to a MLD deeper than KPPmld in the middle of the
26     % ocean, and shallower along the coast.
27     %
28     % 09/20/06
29     % gmaze@mit.edu
30    
31     function compute_MLD(snapshot)
32    
33     global sla toshow
34     global netcdf_suff netcdf_domain
35     global netcdf_SIGMATHETA netcdf_THETA netcdf_SALTanom netcdf_MLD
36     pv_checkpath
37    
38    
39     % NETCDF file name:
40     filST = netcdf_SIGMATHETA;
41     filT = netcdf_THETA;
42     filS = netcdf_SALTanom;
43    
44     % Path and extension to find them:
45     pathname = strcat('netcdf-files',sla);
46     ext = netcdf_suff;
47    
48     % Load files:
49     ferfile = strcat(pathname,sla,snapshot,sla,filST,'.',netcdf_domain,'.',ext);
50     ncST = netcdf(ferfile,'nowrite');
51     ST = ncST{4}(:,:,:);
52     [STlon STlat STdpt] = coordfromnc(ncST);
53    
54     ferfile = strcat(pathname,sla,snapshot,sla,filT,'.',netcdf_domain,'.',ext);
55     ncT = netcdf(ferfile,'nowrite');
56     SST = ncT{4}(1,:,:);
57     [Tlon Tlat Tdpt] = coordfromnc(ncT);
58    
59     ferfile = strcat(pathname,sla,snapshot,sla,filS,'.',netcdf_domain,'.',ext);
60     ncS = netcdf(ferfile,'nowrite');
61     SSS = ncS{4}(1,:,:);
62     [Slon Slat Sdpt] = coordfromnc(ncS);
63    
64    
65     %%%%%%%%%%%%%%%%%%%%%%%%%%%%
66     % COMPUTE The Mixed Layer Depth:
67     %%%%%%%%%%%%%%%%%%%%%%%%%%%%
68     if toshow, disp('pre-allocate'), end
69     nx = length(STlon);
70     ny = length(STlat);
71     SST08 = SST - 0.8;
72     SSS = SSS + 35;
73     Surfadens08 = densjmd95(SSS,SST08,(0.09998*9.81*Tdpt(1))*ones(ny,nx))-1000;
74     MLD = zeros(size(ST,2),size(ST,3));
75    
76     if toshow, disp('get MLD'), end
77     for iy = 1 : size(ST,2)
78     for ix = 1 : size(ST,3)
79     mm = find( squeeze(ST(:,iy,ix)) > Surfadens08(iy,ix) );
80     if ~isempty(mm)
81     MLD(iy,ix) = STdpt(min(mm));
82     end
83     %end
84     end
85     end
86    
87     MLD(isnan(squeeze(ST(1,:,:)))) = NaN;
88    
89     %%%%%%%%%%%%%%%%%%%%%%%%%%%%
90     % Record
91     %%%%%%%%%%%%%%%%%%%%%%%%%%%%
92     if toshow, disp('record'), end
93    
94     % General informations:
95     if ~isempty('netcdf_MLD')
96     netfil = netcdf_MLD;
97     else
98     netfil = 'MLD';
99     end
100     units = 'm';
101     ncid = 'MLD';
102     longname = 'Mixed Layer Depth';
103     uniquename = 'MLD';
104    
105     % Open output file:
106     nc = netcdf(strcat(pathname,sla,snapshot,sla,netfil,'.',netcdf_domain,'.',ext),'clobber');
107    
108     % Define axis:
109     nx = length(STlon) ;
110     ny = length(STlat) ;
111     nz = 1 ;
112    
113     nc('X') = nx;
114     nc('Y') = ny;
115     nc('Z') = nz;
116    
117     nc{'X'} = ncfloat('X');
118     nc{'X'}.uniquename = ncchar('X');
119     nc{'X'}.long_name = ncchar('longitude');
120     nc{'X'}.gridtype = nclong(0);
121     nc{'X'}.units = ncchar('degrees_east');
122     nc{'X'}(:) = STlon;
123    
124     nc{'Y'} = ncfloat('Y');
125     nc{'Y'}.uniquename = ncchar('Y');
126     nc{'Y'}.long_name = ncchar('latitude');
127     nc{'Y'}.gridtype = nclong(0);
128     nc{'Y'}.units = ncchar('degrees_north');
129     nc{'Y'}(:) = STlat;
130    
131     nc{'Z'} = ncfloat('Z');
132     nc{'Z'}.uniquename = ncchar('Z');
133     nc{'Z'}.long_name = ncchar('depth');
134     nc{'Z'}.gridtype = nclong(0);
135     nc{'Z'}.units = ncchar('m');
136     nc{'Z'}(:) = STdpt(1);
137    
138     % And main field:
139     nc{ncid} = ncfloat('Z', 'Y', 'X');
140     nc{ncid}.units = ncchar(units);
141     nc{ncid}.missing_value = ncfloat(NaN);
142     nc{ncid}.FillValue_ = ncfloat(NaN);
143     nc{ncid}.longname = ncchar(longname);
144     nc{ncid}.uniquename = ncchar(uniquename);
145     nc{ncid}(:,:,:) = MLD;
146    
147     nc=close(nc);
148    
149    

  ViewVC Help
Powered by ViewVC 1.1.22