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