Warning, /utils/exch2/matlab-topology-generator/driver.m is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
d7d780aee6 Jean*0001 % Create exch2 communication map and schedule for a cube sphere grid with
b190d42f57 Andr*0002 % constant tile size tnx x tny.
0003
006cfe01c7 Jean*0004 fprintf('Since Oct 13, 2010 (after checkpoint62l), matlab-topology-generator\n');
0005 fprintf(' is no longer supported and does not work anymore (due to additions to\n')
0006 fprintf(' pkg/exch2 which have not been incorporated into the matlab scripts).\n')
0007 fprintf('examples of "data.exch2" file are provided in MITgcm/utils/exch2/input/\n')
0008 return
0009
b190d42f57 Andr*0010 % Use red-green-blue shorthand for cube index space specification
0011 % In this notation cube faces are laid out as shown below
0012 %
8598158690 Jean*0013 % f5(ng,nb) f6(nr,nb)
0014 % f3(nb,nr) f4(ng,nr)
0015 % f1(nr,ng) f2(nb,ng)
d7d780aee6 Jean*0016 %---
8598158690 Jean*0017 %nr=32; ng=64; nb=128;
0018 nr=32; ng=32; nb=32;
0019 %nr=510; ng=510; nb=510;
0020 %nr=30; ng=30; nb=30;
b190d42f57 Andr*0021
d7d780aee6 Jean*0022 %- Choose tile subgrid sizes for each face.
8598158690 Jean*0023 % nr,ng,nb must be integer multiples of tnx and tny.
d7d780aee6 Jean*0024 %---
b190d42f57 Andr*0025 %tnx=85;tny=85;
0026 %tnx=10;tny=10;
0027 %tnx=16;tny=16;
0028 tnx=16;tny=32;
0029 %tnx=32;tny=32;
0030 %tnx=32;tny=8;
0031 %tnx=192;tny=64;
0032 tnx=8;tny=4;
8598158690 Jean*0033 %tnx=16;tny=8; % <- adjustment.cs-32x32x1
d7d780aee6 Jean*0034
0035 %- select option for global-IO mapping: mapIO
0036 % =-1 : old format: put domains 1 after the other in the X direction
0037 % this is not necessary "compact"
0038 % = 1 : compact format, 1 domain after the other (mostly in Y direction)
0039 % but needs to fold some domains (face) if too large
0040 % = 0 : compact format (= 1 long line), one domain after the other
0041 %---
0042 mapIO=-1;
0043
8598158690 Jean*0044 % nr = 90; ng = 360; nb = 90; tnx=90; tny=90; mapIO=1; %- polar-cap grid
0045
d7d780aee6 Jean*0046 if mapIO==1,
8598158690 Jean*0047 %- calculate size in X of global-IO map: = greater divider of nr,ng,nb
0048 [divlist]=exch2_divider([nr ng nb]);
d7d780aee6 Jean*0049 mapIO=prod(divlist);
0050 end
0051
0052 % Make list of domains. Assume MITgcm standard cube layout, three
0053 % color path labeling and global indexing convention.
b190d42f57 Andr*0054 clear domain ndomains domain_nx domain_ny
8598158690 Jean*0055 [ndomains,domain,domain_nx,domain_ny] = exch2_setup_cs6_domains(nr,ng,nb);
b190d42f57 Andr*0056
d7d780aee6 Jean*0057 % Now create basic tile definitions for each domain with their offsets
0058 % within the domain
b190d42f57 Andr*0059 % tn[xy] :: tile extents in x and y
0060 % tbase[xy] :: offset of tile local coords from domain coords
0061 % :: tdom[xy] = tlocal[xy] + tbase[xy]
0062 % t[xy]globallo :: global composite domain coordinate associated with
0063 % :: tlocal[xy]=(1,1)
0064 % mydomain :: domain number the tile belongs to
0065 % tileid :: identifier number for tile
0066 % tx :: tile x coordinate within domain tiling
0067 % ty :: tile y coordinate within domain tiling
0068 clear tile
0069 [tile,ntiles,ierr,domain]= ...
d7d780aee6 Jean*0070 exch2_setup_cs6_tiles(tnx,tny,domain,ndomains,mapIO);
b190d42f57 Andr*0071
0072 % Set neighbor domains for each tile
0073 [tile] = exch2_setup_cs6_get_neighbor_domains(tile, domain, ntiles);
0074
d7d780aee6 Jean*0075 % Let try and figure out what points I send my edges to. We do this by
0076 % a search procedure rather than a functional relationship. The search
0077 % procedure visits each edge of each tile in turn. For internal edges
0078 % (edges that don't cross a domain boundary) the index range at +/-1
0079 % in the normal direction to the edge is searched for. This identifies
0080 % all the tiles that border this tile.
b190d42f57 Andr*0081 [tile] = exch2_setup_cs6_get_internal_neighbor_tiles( tile, domain, ntiles);
0082 [tile] = exch2_setup_cs6_get_internal_neighbor_index_ranges(tile, domain, ntiles);
0083
0084 [tile] = exch2_setup_cs6_get_external_neighbor_tiles( tile, domain, ntiles);
0085
0086 % Draw a picture of the full domain and its tiles in the standard cube layout
0087 % exch2_setup_cs6_plot(domain, tile, tnx, tny);
0088
0089 % Squeeze the blank tiles out
0090 [tile, domain] = exch2_setup_squeeze_blanks(domain, tile, tnx, tny);
0091
0092 % Write attributes for a tile
d7d780aee6 Jean*0093 exch2_setup_cs6_print( domain, tile, tnx, tny, mapIO, 1)