/[MITgcm]/MITgcm_contrib/ifenty/Curvi/input/fixup_grid_edge.m
ViewVC logotype

Contents of /MITgcm_contrib/ifenty/Curvi/input/fixup_grid_edge.m

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


Revision 1.1 - (show annotations) (download)
Wed Jul 5 20:32:37 2006 UTC (19 years ago) by edhill
Branch: MAIN
CVS Tags: HEAD
initial checkin of a script that doubles the size of edge lengths
  and areas to "fixup" the output from SPGrid which only provides
  the fractional contributions from each facet

1 %
2 % Ed Hill
3 %
4 % Quick script to double the lengths/areas around the face edges.
5
6 fin = 'a.face001.bin';
7 fout = 'b.face001.bin';
8
9 sNx = 102;
10 sNy = 41;
11
12 vnall = { 'XC','YC','dxF','dyF','rA','XG','YG','dxV', ...
13 'dyU','rAz','dxC','dyC','rAw','rAs','dxG','dyG' };
14
15 gvars = { 'XC','YC','DXF','DYF','RA','XG','YG','DXV', ...
16 'DYU','RAZ','DXC','DYC','RAW','RAS','DXG','DYG' };
17
18 nslab = (sNx + 1)*(sNy + 1);
19
20 grid = {};
21 for ivar = 1:length(gvars)
22
23 disp([ ' reading : ' gvars{ivar} ]);
24
25 gid = fopen(fin, 'r', 'ieee-be');
26 fseek(gid,(ivar-1)*nslab*8,'bof');
27 tmp = reshape(fread(gid,nslab,'real*8',0,'ieee-be'),[sNx+1,sNy+1]);
28 fclose(gid);
29 grid.(gvars{ivar}) = tmp;
30
31 end
32
33 vn_fonly = { 'XC' 'YC' 'dxF' 'dyF' 'rA' 'XG' 'YG' 'dxG' 'dyG' };
34 vn_fedge = { 'rAw' 'rAs' 'rAz' 'dxV' 'dyU' 'dxC' 'dyC' };
35
36 gnew = grid;
37
38 % RAW
39 gnew.RAW(1 ,:) = 2*grid.RAW(1 ,:); % Bot
40 gnew.RAW(end,:) = 2*grid.RAW(end,:); % Top
41 subplot(1,2,1), surf(grid.RAW)
42 title('old'), shading interp, cax = caxis;
43 subplot(1,2,2), surf(gnew.RAW)
44 title('new'), shading interp, caxis(cax);
45 % RAS
46 gnew.RAS(:,1 ) = 2*grid.RAS(:,1 ); % L
47 gnew.RAS(:,end) = 2*grid.RAS(:,end); % R
48 subplot(1,2,1), surf(grid.RAS)
49 title('old'), shading interp, cax = caxis;
50 subplot(1,2,2), surf(gnew.RAS)
51 title('new'), shading interp, caxis(cax);
52 % RAZ
53 gnew.RAZ(1 ,:) = 2*gnew.RAZ(1 ,:); % Bot
54 gnew.RAZ(end,:) = 2*gnew.RAZ(end,:); % Top
55 gnew.RAZ(:,1 ) = 2*gnew.RAZ(:,1 ); % L
56 gnew.RAZ(:,end) = 2*gnew.RAZ(:,end); % R
57 subplot(1,2,1), surf(grid.RAZ)
58 title('old'), shading interp, cax = caxis;
59 subplot(1,2,2), surf(gnew.RAZ)
60 title('new'), shading interp, caxis(cax);
61 % DXV
62 gnew.DXV(1 ,:) = 2*grid.DXV(1 ,:); % Bot
63 gnew.DXV(end,:) = 2*grid.DXV(end,:); % Top
64 subplot(1,2,1), surf(grid.DXV)
65 title('old'), shading interp, cax = caxis;
66 subplot(1,2,2), surf(gnew.DXV)
67 title('new'), shading interp, caxis(cax);
68 % DYU
69 gnew.DYU(:,1 ) = 2*grid.DYU(:,1 ); % L
70 gnew.DYU(:,end) = 2*grid.DYU(:,end); % R
71 subplot(1,2,1), surf(grid.DYU)
72 title('old'), shading interp, cax = caxis;
73 subplot(1,2,2), surf(gnew.DYU)
74 title('new'), shading interp, caxis(cax);
75 % DXC
76 gnew.DXC(1 ,:) = 2*grid.DXC(1 ,:); % Bot
77 gnew.DXC(end,:) = 2*grid.DXC(end,:); % Top
78 subplot(1,2,1), surf(grid.DXC)
79 title('old'), shading interp, cax = caxis;
80 subplot(1,2,2), surf(gnew.DXC)
81 title('new'), shading interp, caxis(cax);
82 % DYC
83 gnew.DYC(:,1 ) = 2*grid.DYC(:,1 ); % L
84 gnew.DYC(:,end) = 2*grid.DYC(:,end); % R
85 subplot(1,2,1), surf(grid.DYC)
86 title('old'), shading interp, cax = caxis;
87 subplot(1,2,2), surf(gnew.DYC)
88 title('new'), shading interp, caxis(cax);
89
90 fid = fopen(fout, 'w', 'ieee-be');
91 for i = 1:length(gvars)
92 fwrite(fid,gnew.(gvars{i}),'real*8',0,'ieee-be');
93 end
94 fclose(fid);
95

  ViewVC Help
Powered by ViewVC 1.1.22