/[MITgcm]/MITgcm_contrib/mlosch/interp_llc/exch_c.m
ViewVC logotype

Contents of /MITgcm_contrib/mlosch/interp_llc/exch_c.m

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


Revision 1.1 - (show annotations) (download)
Thu May 3 21:07:20 2007 UTC (18 years, 2 months ago) by mlosch
Branch: MAIN
CVS Tags: HEAD
initial checkin of topography and hydrography interpolation scripts for
the llc-grid, based on old matlab scripts by Alistair Adcroft
Let's hope, they are useful.

1 function [b] = exch_c(a,o)
2
3 [nx ny nt]=size(a);
4 if nt == 1
5 elseif nt ~= 6
6 nt
7 error('Must be tiled array (NxNx6)')
8 end
9 if nt == 6 & nx ~= ny
10 [nx ny]
11 error('Tiles must be square (NxNx6)')
12 end
13
14
15 if nt == 6
16 b=NaN*ones(nx+2*o,ny+2*o,6);
17 b(o+1:o+nx,o+1:o+ny,:)=a; % Interior
18 b(o+1:o+nx,o+ny+(1:o),1)=a(1:o,ny:-1:1,3)'; % N-odd
19 b(o+1:o+nx,o+ny+(1:o),3)=a(1:o,ny:-1:1,5)'; % N-odd
20 b(o+1:o+nx,o+ny+(1:o),5)=a(1:o,ny:-1:1,1)'; % N-odd
21 b(o+1:o+nx,1:o,[1 3 5])=a(:,ny-o+1:ny,[6 2 4]); % S-odd
22 b(o+nx+(1:o),o+1:o+ny,[1 3 5])=a(1:o,:,[2 4 6]); % E-odd
23 b(1:o,o+1:o+ny,3)=a(nx:-1:1,ny-o+1:ny,1)'; % W-odd
24 b(1:o,o+1:o+ny,5)=a(nx:-1:1,ny-o+1:ny,3)'; % W-odd
25 b(1:o,o+1:o+ny,1)=a(nx:-1:1,ny-o+1:ny,5)'; % W-odd
26 b(o+1:o+nx,o+ny+(1:o),[2 4 6])=a(:,1:o,[3 5 1]); % N-even
27 b(o+1:o+nx,1:o,2)=a(nx-o+1:nx,ny:-1:1,6)'; % S-even
28 b(o+1:o+nx,1:o,4)=a(nx-o+1:nx,ny:-1:1,2)'; % S-even
29 b(o+1:o+nx,1:o,6)=a(nx-o+1:nx,ny:-1:1,4)'; % S-even
30 b(o+nx+(1:o),o+1:o+ny,2)=a(nx:-1:1,1:o,4)'; % E-even
31 b(o+nx+(1:o),o+1:o+ny,4)=a(nx:-1:1,1:o,6)'; % E-even
32 b(o+nx+(1:o),o+1:o+ny,6)=a(nx:-1:1,1:o,2)'; % E-even
33 b(1:o,o+1:o+ny,[2 4 6])=a(nx-o+1:nx,:,[1 3 5]); % W-even
34 elseif nt == 1
35 b=NaN*ones(nx+2*o,ny+2*o);
36 b(o+1:o+nx,o+1:o+ny)=a; % Interior
37 %b(o+1:o+nx,o+ny+(1:o))=a(:,ny:-1:ny-o+1); % N
38 %b(o+1:o+nx,1:o)=a(:,o:-1:1); % S
39 b(o+nx+(1:o),:)=b(o+1:o+o,:); % E
40 b(1:o,:)=b(o+nx-o+1:o+nx,:); % W
41 end

  ViewVC Help
Powered by ViewVC 1.1.22