1 | function getpot_bry(bryname,grdname,obcndx); |
---|
2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3 | % |
---|
4 | % Get potential temperature of seawater from insitu |
---|
5 | % |
---|
6 | % Further Information: |
---|
7 | % http://www.brest.ird.fr/Roms_tools/ |
---|
8 | % |
---|
9 | % This file is part of ROMSTOOLS |
---|
10 | % |
---|
11 | % ROMSTOOLS is free software; you can redistribute it and/or modify |
---|
12 | % it under the terms of the GNU General Public License as published |
---|
13 | % by the Free Software Foundation; either version 2 of the License, |
---|
14 | % or (at your option) any later version. |
---|
15 | % |
---|
16 | % ROMSTOOLS is distributed in the hope that it will be useful, but |
---|
17 | % WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 | % GNU General Public License for more details. |
---|
20 | % |
---|
21 | % You should have received a copy of the GNU General Public License |
---|
22 | % along with this program; if not, write to the Free Software |
---|
23 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
24 | % MA 02111-1307 USA |
---|
25 | % |
---|
26 | % Copyright (c) 2001-2006 by Pierrick Penven |
---|
27 | % e-mail:Pierrick.Penven@ird.fr |
---|
28 | % |
---|
29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
30 | |
---|
31 | % |
---|
32 | % open the grid file |
---|
33 | % |
---|
34 | ng=netcdf(grdname); |
---|
35 | L=length(ng('xi_rho')); |
---|
36 | M=length(ng('eta_rho')); |
---|
37 | if obcndx==1 |
---|
38 | h=ng{'h'}(1,:); |
---|
39 | suffix='_south'; |
---|
40 | elseif obcndx==2 |
---|
41 | h=ng{'h'}(:,L); |
---|
42 | suffix='_east'; |
---|
43 | elseif obcndx==3 |
---|
44 | h=ng{'h'}(M,:); |
---|
45 | suffix='_north'; |
---|
46 | elseif obcndx==4 |
---|
47 | h=ng{'h'}(:,1); |
---|
48 | suffix='_west'; |
---|
49 | end |
---|
50 | close(ng); |
---|
51 | % |
---|
52 | % open the clim file |
---|
53 | % |
---|
54 | nc=netcdf(bryname,'write'); |
---|
55 | theta_s = nc{'theta_s'}(:); |
---|
56 | theta_b = nc{'theta_b'}(:); |
---|
57 | hc = nc{'hc'}(:); |
---|
58 | N = length(nc('s_rho')); |
---|
59 | tlen = length(nc('bry_time')); |
---|
60 | if tlen==0 |
---|
61 | tlen=1; |
---|
62 | end |
---|
63 | % |
---|
64 | % Get the sigma depths |
---|
65 | % |
---|
66 | P=-1e-4*1025*9.81*squeeze(zlevs(h,0.*h,theta_s,theta_b,hc,N,'r')); |
---|
67 | % |
---|
68 | % loop on time |
---|
69 | % |
---|
70 | for l=1:tlen |
---|
71 | % disp([' Time index: ',num2str(l),' of total: ',num2str(tlen)]) |
---|
72 | T=squeeze(nc{['temp',suffix]}(l,:,:)); |
---|
73 | S=squeeze(nc{['salt',suffix]}(l,:,:)); |
---|
74 | nc{'temp'}(l,:,:)=theta(S,T,P); |
---|
75 | end |
---|
76 | close(nc); |
---|
77 | return |
---|