source: Roms_tools/Preprocessing_tools/rmavgssh.m @ 2

Last change on this file since 2 was 1, checked in by cholod, 13 years ago

import Roms_Agrif

File size: 2.4 KB
Line 
1function rmavgssh(bryname,grdname,obc)
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3%
4%  Remove the averaged SSH in the boundary (bry) files.
5%
6%
7%  Further Information: 
8%  http://www.brest.ird.fr/Roms_tools/
9
10%  This file is part of ROMSTOOLS
11%
12%  ROMSTOOLS is free software; you can redistribute it and/or modify
13%  it under the terms of the GNU General Public License as published
14%  by the Free Software Foundation; either version 2 of the License,
15%  or (at your option) any later version.
16%
17%  ROMSTOOLS is distributed in the hope that it will be useful, but
18%  WITHOUT ANY WARRANTY; without even the implied warranty of
19%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20%  GNU General Public License for more details.
21%
22%  You should have received a copy of the GNU General Public License
23%  along with this program; if not, write to the Free Software
24%  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25%  MA  02111-1307  USA
26%
27%  Copyright (c) 2001-2006 by Pierrick Penven
28%  e-mail:Pierrick.Penven@ird.fr 
29%
30%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31disp(' ');
32disp('Remove averaged SSH ...');
33
34ng=netcdf(grdname);
35L=length(ng('xi_rho'));
36M=length(ng('eta_rho'));
37
38nc=netcdf(bryname,'write');
39time=nc{'bry_time'}(:);
40tlen=length(time);
41
42
43for l=1:tlen
44%for l=1:1
45  tssh=0;
46  S=0;
47  for obcndx=1:4
48    if obc(obcndx)==1
49      if obcndx==1
50        pm=ng{'pm'}(1,:);
51        pn=ng{'pn'}(1,:);
52        rmask=ng{'mask_rho'}(1,:);
53        suffix='_south';
54      elseif obcndx==2
55        pm=(ng{'pm'}(:,L))';
56        pn=(ng{'pn'}(:,L))';
57        rmask=(ng{'mask_rho'}(:,L))';
58        suffix='_east';
59      elseif obcndx==3
60        pm=ng{'pm'}(M,:);
61        pn=ng{'pn'}(M,:);
62        rmask=ng{'mask_rho'}(M,:);
63        suffix='_north';
64      elseif obcndx==4
65        pm=(ng{'pm'}(:,1))';
66        pn=(ng{'pn'}(:,1))';
67        rmask=(ng{'mask_rho'}(:,1))';
68        suffix='_west';
69      end
70      Nx=length(pm);
71      ssh=nc{['zeta',suffix]}(l,:);
72      tssh=tssh+sum(rmask.*ssh./(pm.*pn));
73      S=S+sum(rmask./(pm.*pn));
74    end
75  end
76  avgssh=tssh./S;
77  for obcndx=1:4
78    if obc(obcndx)==1
79      if obcndx==1
80        suffix='_south';
81      elseif obcndx==2
82        suffix='_east';
83      elseif obcndx==3
84        suffix='_north';
85      elseif obcndx==4
86        suffix='_west';
87      end
88      ssh=nc{['zeta',suffix]}(l,:);
89      nc{['zeta',suffix]}(l,:)=ssh-avgssh;
90    end
91  end
92end
93close(ng)
94close(nc)
Note: See TracBrowser for help on using the repository browser.