function [] = sw_test()
% SW_TEST Test SEAWATER Library Routines
%=========================================================================
% SW_TEST $Id: sw_test.m,v 1.1 2003/12/12 04:23:22 pen078 Exp $
% Copyright (C) CSIRO, Phil Morgan 1994
%
% sw_test
%
% DESCRIPTION:
% Execute test routines to test and verify SEAWATER Library routines
% for your platform. Prints output to screen and to file sw_test.txt
%
% Use the "more" command to scroll results to screen
%
% OUTPUT:
% file sw_test.txt
%
% AUTHOR: Phil Morgan, Lindsay Pender (Lindsay.Pender@csiro.au)
%
% DISCLAIMER:
% This software is provided "as is" without warranty of any kind.
% See the file sw_copy.m for conditions of use and licence.
%
%=========================================================================
% Modifications
% 03-12-12. Lindsay Pender, Converted to ITS-90.
delete sw_test.txt
disp('OUTPUT FROM THIS TEST WILL ALSO BE SAVED IN FILE sw_test.txt')
disp(' <enter> to continue...')
pause
reply = input('Full listing of help for each routine (y/n) ? ','s');
display_help = strcmp(reply,'y') | strcmp(reply,'Y');
format compact
echo off
diary sw_test.txt
disp( '***********************')
disp( ' TEST REPORT ')
disp( ' ')
disp( ' SEA WATER LIBRARY ')
disp( ' ')
sw_ver
disp( ' ')
disp(['Matlab Version ' version ])
disp( ' ')
disp([' ' date ''])
disp( '***********************')
disp(' ')
%--------------------------------
% TEST MAIN MODULE sw_ptmp.m
% SUB-MODULES sw_atg.m
%--------------------------------
module = 'sw_ptmp';
submodules = 'sw_adtg.m';
disp('*************************************')
disp(['** TESTING MODULE: ' module])
disp(['** and SUB-MODULE: ' submodules])
disp('*************************************')
if display_help
eval(['help ' module])
eval(['help ' submodules])
end %if
% TEST 1 - data from Unesco 1983 p45
T = [ 0 0 0 0 0 0;
10 10 10 10 10 10;
20 20 20 20 20 20;
30 30 30 30 30 30;
40 40 40 40 40 40 ]/1.00024;
S = [25 25 25 35 35 35;
25 25 25 35 35 35;
25 25 25 35 35 35 ;
25 25 25 35 35 35;
25 25 25 35 35 35 ];
P = [0 5000 10000 0 5000 10000;
0 5000 10000 0 5000 10000;
0 5000 10000 0 5000 10000 ;
0 5000 10000 0 5000 10000;
0 5000 10000 0 5000 10000 ];
Pr = [0 0 0 0 0 0];
UN_ptmp = [ 0 -0.3061 -0.9667 0 -0.3856 -1.0974;
10 9.3531 8.4684 10 9.2906 8.3643;
20 19.0438 17.9426 20 18.9985 17.8654;
30 28.7512 27.4353 30 28.7231 27.3851;
40 38.4607 36.9254 40 38.4498 36.9023];
ptmp = sw_ptmp(S,T,P,Pr)*1.00024;
%----------------
% DISPLAY RESULTS
%----------------
disp(' ')
disp ('********************************************************')
disp ('Comparison of accepted values from UNESCO 1983 ')
disp (' (Unesco Tech. Paper in Marine Sci. No. 44, p45)')
disp (['with computed results from ' module ' on ' computer ' computer'])
disp ('********************************************************')
for icol = 1:length(S(1,:))
disp(' ')
disp (' Sal Temp Press PTMP sw_ptmp')
disp (' (psu) (C) (db) (C) (C)')
fprintf(1,' %4.0f %4.0f %5.0f %8.4f %11.5f\n', ...
[S(:,icol) T(:,icol) P(:,icol) UN_ptmp(:,icol) ptmp(:,icol)]');
end %for
%-------------------------------------------------------------------------------
% TEST MAIN MODULE sw_svan.m
% SUB-MODULES sw_dens.m sw_dens0.m sw_smow.m sw_seck.m sw_pden.m sw_ptmp.m
%------------------------------------------------------------------------------
module = 'sw_svan.m';
submodules = 'sw_dens.m sw_dens0.m sw_smow.m sw_seck.m sw_pden.m sw_ptmp.m';
disp(' ')
disp('************************************************************************')
disp(['** TESTING MODULE: ' module])
disp(['** and SUB-MODULE: ' submodules])
disp('************************************************************************')
if display_help
eval(['help ' module])
eval(['help ' submodules])
end %if
% TEST DATA FROM
% Unesco Tech. Paper in Marine Sci. No. 44, p22
s = [0 0 0 0 35 35 35 35]';
p = [0 10000 0 10000 0 10000 0 10000]';
t = ([0 0 30 30 0 0 30 30] / 1.00024)';
UN_svan = [2749.54 2288.61 3170.58 3147.85 ...
0.0 0.00 607.14 916.34]';
svan = sw_svan(s,t,p);
%----------------
% DISPLAY RESULTS
%----------------
disp(' ')
disp ('********************************************************')
disp ('Comparison of accepted values from UNESCO 1983')
disp (' (Unesco Tech. Paper in Marine Sci. No. 44, p22)')
disp (['with computed results from ' module ' on ' computer ' computer'])
disp ('********************************************************')
disp(' ')
disp (' Sal Temp Press SVAN sw_svan')
disp (' (psu) (C) (db) (1e-8*m3/kg) (1e-8*m3/kg)')
fprintf(1,' %4.0f %4.0f %5.0f %11.2f %11.3f\n',[s t p UN_svan 1e+8*svan]');
%-------------------------------------------------------------------------------
% TEST MAIN MODULE
% SUB-MODULES
%------------------------------------------------------------------------------
module = 'sw_salt.m';
submodules = 'sw_salrt.m sw_salrp.m sw_sals.m';
disp(' ')
disp('************************************************************************')
disp(['** TESTING MODULE: ' module])
disp(['** and SUB-MODULE: ' submodules])
disp('************************************************************************')
if display_help
eval(['help ' module])
eval(['help ' submodules])
end %if
% TEST 1 - data from Unesco 1983 p9
%***************************************************************************
R = [1 1.2 0.65]'; % cndr = R
T = ([15 20 5]/1.00024)';
P = [0 2000 1500]';
Rt = [1 1.0568875 0.81705885]';
UN_S = [35 37.245628 27.995347]';
S = sw_salt(R,T,P);
%----------------
% DISPLAY RESULTS
%----------------
disp(' ')
disp ('********************************************************')
disp ('Comparison of accepted values from UNESCO 1983 ')
disp (' (Unesco Tech. Paper in Marine Sci. No. 44, p9)')
disp (['with computed results from ' module ' on ' computer ' computer'])
disp ('********************************************************')
disp(' ')
disp (' Temp Press R S sw_salt')
disp (' (C) (db) (no units) (psu) (psu) ')
table = [T P R UN_S S]';
fprintf(1,' %4.0f %4.0f %8.2f %11.6f %14.7f\n', table);
%-------------------------------------------------------------------------------
% TEST MAIN MODULE
% SUB-MODULES
%------------------------------------------------------------------------------
module = 'sw_cndr.m';
submodules = 'sw_salds.m';
disp(' ')
disp('************************************************************************')
disp(['** TESTING MODULE: ' module])
disp(['** and SUB-MODULE: ' submodules])
disp('************************************************************************')
if display_help
eval(['help ' module])
eval(['help ' submodules])
end %if
% TEST 1 - data from Unesco 1983 p9
T = ([0 10 0 10 10 30]/1.00024)';
P = [0 0 1000 1000 0 0]';
S = [25 25 25 25 40 40]';
UN_R = [ 0.498088 0.654990 0.506244 0.662975 1.000073 1.529967]';
R = sw_cndr(S,T,P);
%----------------
% DISPLAY RESULTS
%----------------
disp(' ')
disp ('********************************************************')
disp ('Comparison of accepted values from UNESCO 1983 ')
disp (' (Unesco Tech. Paper in Marine Sci. No. 44, p14)')
disp (['with computed results from ' module ' on ' computer ' computer'])
disp ('********************************************************