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

Contents of /MITgcm_contrib/mlosch/interp_llc/exch_llc.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_llc(a,o)
2
3 [nnx nny]=size(a);
4
5 if (nnx/4~=round(nnx/4))
6 error('x-dimension needs to be divisible by 4')
7 end
8 n4 = nnx/4;
9 % pull array appart
10 ca = a(:,end-n4+1:end);
11 lla = a(:,1:end-n4);
12 % do the tricky bit first because we need the ll part for that
13 [nx,ny]=size(ca);
14 lln = lla(:,end-o+1:end);
15 cb = NaN*ones(nx+2*o,ny+o);
16 % interior
17 cb(o+1:nx+o,1:ny)=ca;
18 %
19 cb(1:o,:) = flipud(lln(n4*3-o+1:n4*4,:))'; % right
20 cb(end-o+1:end,:) = fliplr(lln(1:n4+o,:))'; % left
21 % top
22 cb(o+1:o+n4,end-o+1:end) = flipud(fliplr(lln(2*n4+1:3*n4,:)));
23 cb(o+n4+1:o+2*n4,end-o+1:end) = fliplr(flipud(lln(n4*3+1:n4*4,:)));
24 cb(o+n4*2+1:o+3*n4,end-o+1:end) = flipud(lln(1:n4,:));
25 cb(o+n4*3+1:o+4*n4,end-o+1:end) = flipud(lln(2*n4+1:3*n4,:));
26
27 % now exchange regular part:
28 [nx,ny]=size(lla);
29 llb=NaN*ones(nx+2*o,ny+o);
30 llb(o+1:o+nx,o+1:o+ny)=lla; % Interior
31 %b(o+1:o+nx,o+ny+(1:o))=a(:,ny:-1:ny-o+1); % N
32 %b(o+1:o+nx,1:o)=a(:,o:-1:1); % S
33 llb(o+nx+(1:o),:)=llb(o+1:o+o,:); % E
34 llb(1:o,:)=llb(o+nx-o+1:o+nx,:); % W
35
36 % put both parts together
37
38 b = [llb cb];
39
40
41

  ViewVC Help
Powered by ViewVC 1.1.22