runomp2.m  the startup window for OMP Analysis (calls one of omp2auto.m, omp2gui.m or omp2int.m); 
omp2auto.m  the routine to run the analysis from a control file (calls omp2.m); 
omp2int.m  the routine to run the analysis in interactive mode via the Matlab control window (calls omp2.m); 
omp2gui.m  the routine to run the analysis in interactive mode via the graphical user interface (calls omp2.m); 
omp2.m  the core of the package which solves the overdetermined linear system of equations (may call contour2.m depending on user input); 
contour2.m  a routine to contour water mass fractions across a hydrographic section against pressure and distance between stations; 
displtxt.m  a text display routine used by runomp2.m and ompgui.m; 
fontset.m  a small routine which sets font type and font size for text display and can be edited to suit your monitor; 
helpomp.m  displays help for runomp2.m; 
helpint.m  displays help for omp2gui.m; 
incontr2.m  the default control file used by omp2auto.m which can be copied and edited to change run parameters; 
qwt2.m  the list of water type definitions used by all routines which can be copied and edited to suit your application requirements; 
norm_qwt.m  a routine to convert the source water type information from qwt2.m into a matrix; 
def_sources.m  a routine to determine source water types for water masses of the thermocline; 
nansum.m  a Matltab routine by Phil Morgan which builds sums ignoring NaNs; 
statns2.m  a routine to sort water type results from omp2.m and residuals, latitude and longitude into increasing pressure and produce new arrays which can be studied as individual stations. 
displvar.m  a routine which displays individual stations from output produced by statns2.m. 
sortomp2.m  a routine which sorts water type results and residuals, latitude and longitude into increasing pressure and writes the data as sections into ASCII files in a format which is recognized by Transform (Spyglass/Fortner) and Noesys (Fortner) and useful for other graphing software. 
sortwrt.m  a routine used by sortomp2.m to store individual data types (required for compatibility with OMP Analysis version 1). 
drswitch.m  a routine used by omp2.m to allow a change of directory during program execution. 
testdata.mat  the default data file used to test run omp2auto.m, omp2gui.m and omp2int.m; 
testwght.mat  the default weights and Redfield ratios used to test run omp2auto.m, omp2gui.m and omp2int.m; 
testlevels.mat  the default depth levels used by sortomp2.m; 
The hydrographic structure in the example region, the eastern troipcal Indian Ocean, is dominated by two water masses in the thermocline, Indian Central Water (ICW) and the water mass of the Indonesian Throughflow known as Australasian Mediterranean Water (AAMW), which meet and mix here. We therefore assume to see an intense frontal structure in the upper few hundred metres above a diffuse signal from Antarctic Intermediate Water. A simple salinity section will show us this immediately, but for some reason we are interested in quantifying the fractions of individual water masses, say to resolve the effects of mixing on a CFC distribution.
The water masses of the permanent thermocline (in this case ICW and AAMW) cover a wide depth (temperature) range and must therefore be represented by 2 source water types each. AAIW is more uniform in its formation region and can be represented by a single water type. Depending on the depth range of interest we thus require at least 4 and possibly 5 water types for the analysis.
The variables used in the OMP Analysis Matlab package and their defined names are listed below:
lat  latitude: essential 
long  longitude: essential 
press  pressure: essential 
sal  salinity: essential 
temp  temperature: essential unless potential temperature is supplied 
ptemp  potential temperature: optional (will be calculated if not supplied) 
pdens  potential density: optional (will be calculated if not supplied) 
oxy  oxygen: optional 
ph  phosphate: optional 
ni  nitrate: optional 
si  silicate: optional 
pvort  10^{8} * potential vorticity: optional (will be calculated if requested) 
comment  data comments (region, cruise, date etsc): optional 
The listed data have to be supplied as a .mat file. To prepare your data as a .mat file, arrage them as a plain ASCII file with one variable per column, load the ASCII file from the Matlab command window and save all variables into a .mat file. (See the page The Matlab code of this manual if you do not know how to do this.) Data gaps should be filled with a dummy value of 9 or less. If you include potential vorticity in your data it must be multiplied by 10^{8}. If you do not include potential vorticity but want the program to calculate it, pressure has to increase for every station (no duplicate samples at identical depths, no data from up casts).
% wm(1:5) = ' AAMW'; % first row % wm(6:10) = ' AAMW'; % second row % wm(11:15) = ' ICW'; %upper, first set third row % wm(16:20) = ' ICW'; %lower, first set forth row % wm(21:25) = ' ICW'; %upper, second set fifth row % wm(26:30) = ' ICW'; %lower, second set sixth row % wm(31:35) = ' AAIW'; % seventh row % wm(36:40) = ' IEW'; % eigth row all=[... % The following lines define the water types. The order of parameters is % ptemp sal oxy PO4 NO3 Si mass pvort % Note: potential vorticity is multiplied by 10*8. 10 34.56 91 2.1 30 40 1.0 0.03;... %1 lower AAMW 16.4 34.55 100 1.4 19 25 1.0 1.12;... %2 upper AAMW 9 34.65 260 1.1 15 5 1.0 0.03;... %3 lower ICW, first set 18 35.8 230 0 0 0.5 1.0 0.05;... %4 upper ICW, first set 9 34.72 209 1.47 20 5 1.0 0.03;... %5 lower ICW, second set 14.35 35.4 224 0.6 6.5 0.5 1.0 0.05;... %6 upper ICW, second set 4.5 34.35 210 2.2 32 35 1.0 0.30;... %7 AAIW 8.5 35 60 2.5 35 60 1.0 0.04;... %8 IEW ]; G1=all(wm_row,:)'; allsize = size(all);
There is one water mass name for each water type definition row. Each name has to consist of exactly 5 letters including blanks; DO NOT CHANGE THE LENGTH unless you want to edit the main program omp2.m, too!
NOTES:
The water type definition for Antarctic Intermediate Water (AAIW) is relatively easy to find by identifying the AAIW salinity minimum and determining all other parameters at that salinity. The definition of Australasian Mediterranean Water (AAMW) and Indian Central Water (ICW) relies on a linear approximation of the propertyproperty relationships across the thermocline and can be determined by a best linear fit procedure. To determine the temperature range with approximately linear relationships between
all parameters, we used the Matlab script polyfit.m.
It delivers (with the script polyval.m) an error estimate of the fit as well.
This error can be useful in detecting the upper and lower
limit of linear parameter behavior as well as to calculate the weights for the OMP analysis (see section 2.2).
The Matlab routine def_sources.m can be used to find water types in the permanent thermocline in this manner. Table 3.1 shows an example of this calculation for one thermocline water mass (AAMW).

The water type definitions or source water types G_{ji} for a thermocline water mass are then given by the end points of the lines in Figure 3.1 (listed for AAMW in Table 3.1). All other points on these lines are also source water types; together with d_{j} they define the water mass completely. OMP analysis handles this situation by mathematically representing all source water types on the lines as mixtures from the two source water types at the end of the lines.
Figure 3.2 compares the data set given by testdata (from OMP Analysis version 1.0) with the water mass definitions for AAMW and ICW thus obtained. Note that no data points come close to the ICW definition because its formation region is far away from the region covered by the observations.
Wx = 24 0 0 0 0 0 0 0 0 24 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 24 0 0 0 0 0 0 0 0 24 
ratio = 0 0 170 1 16 40 0 0 
Weights and Redfield ratios are given in the order
In our example the weights are calculated from the mean variance of the linear fit to the data in the source region, related to the variance in the source water type matrix (calculated with the 'stdG' output from norm_qwt.m; see section 2.2 for details). Column 4 in table 3.1 summarizes the so calculated values. With the weighting formula (see section 2.2 for details) we obtain the weights for each parameter. Mass conservation is usually given the same weight as the weight of the parameter with the highest weight, but other choices are of course possible.
Weights for water masses represented by a single source water type are calculated from the variability around that point in parameter space.
The Redfield ratios given in testwght are suggestions based on our best understanding of the Indian Ocean thermocline. Without doubt you will have to make your own decision on the most correct Redfield ratios.
Run the script runomp2.m (type the command runomp2 in the command window). The OMP Analysis title screen will appear. It gives you the choice of running the analysis automatically from a control file, interactively from a graphical user interface, or interactively through the command window. You can select either of the interactive choices and enter the names of your files in response when prompted. If you want to run the analysis in automatic mode you have to prepare a control script which contains automatic answers to the various prompts that occur at run time. The default control script is incontr2.m, which looks like this:
% Set type of OMP analysis by placing/deleting comment (%) sign: OMP = 'cla'; % classical OMP analysis %OMP = 'ext'; % extended OMP analysis % Define the file which contains the data by replacing the word testdata: dataset = 'testdata'; % Set upper and lower limit of the analysis range (pressure in dbar): uplimit = 0; lolimit = 6000; % Select/deselect potential vorticity by setting switchpot to 'y' or 'n': switchpot = 'n'; % Select/deselect variables by setting corresponding switches to 'y' or 'n': iox = 'y'; % oxygen switch iph = 'y'; %phosphate switch ini = 'y'; % nitrate switch isi = 'n'; %silicate switch % Define the file which contains the weights and Redfield ratios % by replacing the word testwght: weightset = 'testwght'; % Set the total number of water masses to be included in the analysis wm = 4; % Select the water type numbers (rows in the water type matrix) % (The square brackets have to contain wm numbers): qwt_pos = [1 2 3 4];
The script is more or less selfexplanatory. We suggest that you save incontr2.m under a different name before you edit it to your requirements. That way you can always return to the default test run to verify that your programs are working correctly.
When you run the analysis you will see a progress report in the command window, followed by a summary of your run which lists all file names, weights, water types and Redfield ratios used. The program then pauses, allowing you to review the run. Pressing any key produces a plot of the mass conservation residual as a function of potential density, giving you a rough indication of the quality of your solution. Further output in the form of water mass fractions against depth is produced on demand.