/[MITgcm]/MITgcm_contrib/high_res_cube/matlab-grid-generator/bin/generate_grid.m
ViewVC logotype

Contents of /MITgcm_contrib/high_res_cube/matlab-grid-generator/bin/generate_grid.m

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


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Nov 11 18:08:08 2003 UTC (23 years ago) by cnh
Branch: MAIN, initial
CVS Tags: baseline, HEAD
Changes since 1.1: +0 -0 lines
Checking in work done with Dimitri on high-resolution cube gridding and parallel 
communications. 
   o code is in a contrib experiment for now so we can continue collaborating
     on it. However most code is general and will be moved into main branch once 
     it is fully hardened.
   o There are README files in the contrib root and in the subdirectories that
     explain the contents

1 function [G] = generate_grid(varargin)
2 % generate_grid(dlon,dllat)
3 % generate_grid(dlon,dllat,lon0,lat0)
4 % generate_grid(dlon,dllat,lon0,lat0,mask)
5
6 switch nargin
7 case {2}
8 dlon=varargin{1};
9 dlat=varargin{2};
10 lon0=0;
11 lat0=-90;
12 case {4,5}
13 dlon=varargin{1};
14 dlat=varargin{2};
15 lon0=varargin{3};
16 lat0=varargin{4};
17 otherwise
18 error('Wrong number of arguments')
19 end
20
21 [G.xc,G.yc,G.xg,G.yg,G.rac,G.dxg,G.dyg]=grid_sphere(dlon,dlat,lon0,lat0);
22 %[G.xc,G.yc,G.xg,G.yg]=grid_sphere(dlon,dlat,lon0,lat0);
23
24 if nargin<=4
25 return
26 end
27
28 G.mskc=mask(varargin{5});
29
30 if prod( size(G.mskc(:,:,1)) == [size(G.xc,1) size(G.yc,2)] )==0
31 disp('Size of mask argument:');size(G.mskc(:,:,1))
32 error('Mask argument (5) has incompatible dimensions with grid')
33 end
34
35 [xc,yc]=ndgrid(G.xc,G.yc);
36
37 xc( find(xc<0) )=xc( find(xc<0) )+360;
38
39 mskc=G.mskc(:,:,1);
40 j=[];
41 j=[j find( yc>-32.5 & xc>290 )'];
42 j=[j find( yc>-32.5 & xc<25 )'];
43 %j=[j find( yc>-32 & yc+xc>287 )'];
44 j=[j find( yc>9 & yc<60 & (yc-10)+(xc-276)>0 )'];
45 j=[j find( yc>17 & yc<60 & xc>261 )'];
46 j=[j find( yc>50 & (yc-70)-(xc-270)<0 )'];
47 j=[j find( yc>64 & xc<100 & xc>0 )'];
48 j=[j find( yc>31 & yc<44 & xc<38 & xc>0 )'];
49 matl=0*mskc;
50 matl(j)=1;
51 matl=matl.*mskc;
52 G.matl=matl;
53
54 mpac=(1-matl).*mskc;
55 j=[];
56 j=[j find( yc>-32.5 & yc<65 )'];
57 mpac=0*mskc;
58 mpac(j)=1;
59 mpac=mpac.*mskc.*(1-matl);
60 G.mpac=mpac;
61
62 msoc=(1-matl).*(1-mpac).*mskc;
63 j=[];
64 j=[j find( yc<0 )'];
65 G.msoc=msoc.*mskc.*(1-mpac).*(1-matl);

  ViewVC Help
Powered by ViewVC 1.1.22