1 |
jmc |
1.5 |
% $Header: /u/gcmpack/MITgcm/utils/exch2/matlab-topology-generator/driver.m,v 1.4 2009/05/02 02:41:05 jmc Exp $ |
2 |
jmc |
1.2 |
% $Name: $ |
3 |
|
|
|
4 |
jmc |
1.3 |
% Create exch2 communication map and schedule for a cube sphere grid with |
5 |
afe |
1.1 |
% constant tile size tnx x tny. |
6 |
|
|
|
7 |
jmc |
1.5 |
fprintf('Since Oct 13, 2010 (after checkpoint62l), matlab-topology-generator\n'); |
8 |
|
|
fprintf(' is no longer supported and does not work anymore (due to additions to\n') |
9 |
|
|
fprintf(' pkg/exch2 which have not been incorporated into the matlab scripts).\n') |
10 |
|
|
fprintf('examples of "data.exch2" file are provided in MITgcm/utils/exch2/input/\n') |
11 |
|
|
return |
12 |
|
|
|
13 |
afe |
1.1 |
% Use red-green-blue shorthand for cube index space specification |
14 |
|
|
% In this notation cube faces are laid out as shown below |
15 |
|
|
% |
16 |
jmc |
1.4 |
% f5(ng,nb) f6(nr,nb) |
17 |
|
|
% f3(nb,nr) f4(ng,nr) |
18 |
|
|
% f1(nr,ng) f2(nb,ng) |
19 |
jmc |
1.3 |
%--- |
20 |
jmc |
1.4 |
%nr=32; ng=64; nb=128; |
21 |
|
|
nr=32; ng=32; nb=32; |
22 |
|
|
%nr=510; ng=510; nb=510; |
23 |
|
|
%nr=30; ng=30; nb=30; |
24 |
afe |
1.1 |
|
25 |
jmc |
1.3 |
%- Choose tile subgrid sizes for each face. |
26 |
jmc |
1.4 |
% nr,ng,nb must be integer multiples of tnx and tny. |
27 |
jmc |
1.3 |
%--- |
28 |
afe |
1.1 |
%tnx=85;tny=85; |
29 |
|
|
%tnx=10;tny=10; |
30 |
|
|
%tnx=16;tny=16; |
31 |
|
|
tnx=16;tny=32; |
32 |
|
|
%tnx=32;tny=32; |
33 |
|
|
%tnx=32;tny=8; |
34 |
|
|
%tnx=192;tny=64; |
35 |
|
|
tnx=8;tny=4; |
36 |
jmc |
1.4 |
%tnx=16;tny=8; % <- adjustment.cs-32x32x1 |
37 |
jmc |
1.3 |
|
38 |
|
|
%- select option for global-IO mapping: mapIO |
39 |
|
|
% =-1 : old format: put domains 1 after the other in the X direction |
40 |
|
|
% this is not necessary "compact" |
41 |
|
|
% = 1 : compact format, 1 domain after the other (mostly in Y direction) |
42 |
|
|
% but needs to fold some domains (face) if too large |
43 |
|
|
% = 0 : compact format (= 1 long line), one domain after the other |
44 |
|
|
%--- |
45 |
|
|
mapIO=-1; |
46 |
|
|
|
47 |
jmc |
1.4 |
% nr = 90; ng = 360; nb = 90; tnx=90; tny=90; mapIO=1; %- polar-cap grid |
48 |
|
|
|
49 |
jmc |
1.3 |
if mapIO==1, |
50 |
jmc |
1.4 |
%- calculate size in X of global-IO map: = greater divider of nr,ng,nb |
51 |
|
|
[divlist]=exch2_divider([nr ng nb]); |
52 |
jmc |
1.3 |
mapIO=prod(divlist); |
53 |
|
|
end |
54 |
|
|
|
55 |
|
|
% Make list of domains. Assume MITgcm standard cube layout, three |
56 |
|
|
% color path labeling and global indexing convention. |
57 |
afe |
1.1 |
clear domain ndomains domain_nx domain_ny |
58 |
jmc |
1.4 |
[ndomains,domain,domain_nx,domain_ny] = exch2_setup_cs6_domains(nr,ng,nb); |
59 |
afe |
1.1 |
|
60 |
jmc |
1.3 |
% Now create basic tile definitions for each domain with their offsets |
61 |
|
|
% within the domain |
62 |
afe |
1.1 |
% tn[xy] :: tile extents in x and y |
63 |
|
|
% tbase[xy] :: offset of tile local coords from domain coords |
64 |
|
|
% :: tdom[xy] = tlocal[xy] + tbase[xy] |
65 |
|
|
% t[xy]globallo :: global composite domain coordinate associated with |
66 |
|
|
% :: tlocal[xy]=(1,1) |
67 |
|
|
% mydomain :: domain number the tile belongs to |
68 |
|
|
% tileid :: identifier number for tile |
69 |
|
|
% tx :: tile x coordinate within domain tiling |
70 |
|
|
% ty :: tile y coordinate within domain tiling |
71 |
|
|
clear tile |
72 |
|
|
[tile,ntiles,ierr,domain]= ... |
73 |
jmc |
1.3 |
exch2_setup_cs6_tiles(tnx,tny,domain,ndomains,mapIO); |
74 |
afe |
1.1 |
|
75 |
|
|
% Set neighbor domains for each tile |
76 |
|
|
[tile] = exch2_setup_cs6_get_neighbor_domains(tile, domain, ntiles); |
77 |
|
|
|
78 |
jmc |
1.3 |
% Let try and figure out what points I send my edges to. We do this by |
79 |
|
|
% a search procedure rather than a functional relationship. The search |
80 |
|
|
% procedure visits each edge of each tile in turn. For internal edges |
81 |
|
|
% (edges that don't cross a domain boundary) the index range at +/-1 |
82 |
|
|
% in the normal direction to the edge is searched for. This identifies |
83 |
|
|
% all the tiles that border this tile. |
84 |
afe |
1.1 |
[tile] = exch2_setup_cs6_get_internal_neighbor_tiles( tile, domain, ntiles); |
85 |
|
|
[tile] = exch2_setup_cs6_get_internal_neighbor_index_ranges(tile, domain, ntiles); |
86 |
|
|
|
87 |
|
|
[tile] = exch2_setup_cs6_get_external_neighbor_tiles( tile, domain, ntiles); |
88 |
|
|
|
89 |
|
|
% Draw a picture of the full domain and its tiles in the standard cube layout |
90 |
|
|
% exch2_setup_cs6_plot(domain, tile, tnx, tny); |
91 |
|
|
|
92 |
|
|
% Squeeze the blank tiles out |
93 |
|
|
[tile, domain] = exch2_setup_squeeze_blanks(domain, tile, tnx, tny); |
94 |
|
|
|
95 |
|
|
% Write attributes for a tile |
96 |
jmc |
1.3 |
exch2_setup_cs6_print( domain, tile, tnx, tny, mapIO, 1) |