/[MITgcm]/MITgcm_contrib/eh3/llc/ecco-godae/input/rotate_grid.m
ViewVC logotype

Annotation of /MITgcm_contrib/eh3/llc/ecco-godae/input/rotate_grid.m

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


Revision 1.1 - (hide annotations) (download)
Mon Nov 13 01:39:57 2006 UTC (18 years, 8 months ago) by edhill
Branch: MAIN
initial ci

1 edhill 1.1 %
2     % Rotate the grid by -37 degrees longitude
3     %
4    
5     rlon = -37.0;
6    
7     gvars = { 'XC','YC','DXF','DYF','RA','XG','YG','DXV', ...
8     'DYU','RAZ','DXC','DYC','RAW','RAS','DXG','DYG' };
9    
10     i = 1;
11     for i = [ 1:5 ]
12    
13     fbname = sprintf('llc_p90_%d',i);
14     eval([ '!cp ' fbname '.nc ' fbname '_rot.nc' ]);
15     % eval([ '!cp ' fbname '.mitgrid ' fbname '_rot.mitgrid' ]);
16    
17     nc = netcdf([ fbname '_rot.nc' ],'write');
18     nxp1 = length( nc('Xp1') ); nx = nxp1 - 1;
19     nyp1 = length( nc('Yp1') ); ny = nyp1 - 1;
20     XCo = [];
21     XGo = [];
22     XCo = nc{'XC'}(:);
23     XGo = nc{'XG'}(:);
24     XC = XCo + rlon;
25     XG = XGo + rlon;
26     icp = find( XC(:) < -180.0 ); XC(icp) = XC(icp) + 360.0;
27     icm = find( XC(:) > 180.0 ); XC(icm) = XC(icm) - 360.0;
28     igp = find( XG(:) < -180.0 ); XG(icp) = XG(icp) + 360.0;
29     igm = find( XG(:) > 180.0 ); XG(icm) = XG(icm) - 360.0;
30     nc{'XC'}(:) = XC(:);
31     nc{'XG'}(:) = XG(:);
32    
33     gid = fopen([ fbname '.mitgrid' ], 'r', 'ieee-be');
34     tmp = reshape(fread(gid,inf,'real*8',0,'ieee-be'),[nxp1*nyp1,16]);
35     XC = tmp(:,1) + rlon;
36     XG = tmp(:,6) + rlon;
37     icp = find( XC(:) < -180.0 ); XC(icp) = XC(icp) + 360.0;
38     icm = find( XC(:) > 180.0 ); XC(icm) = XC(icm) - 360.0;
39     igp = find( XG(:) < -180.0 ); XG(icp) = XG(icp) + 360.0;
40     igm = find( XG(:) > 180.0 ); XG(icm) = XG(icm) - 360.0;
41     tmp(:,1) = XC;
42     tmp(:,6) = XG;
43     fclose( gid );
44    
45     gid = fopen([ fbname '_rot.mitgrid' ], 'w', 'ieee-be');
46     fwrite(gid,tmp,'real*8');
47     fclose( gid );
48    
49     end
50    

  ViewVC Help
Powered by ViewVC 1.1.22