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

Contents 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.2 - (show annotations) (download)
Mon Nov 13 03:21:07 2006 UTC (18 years, 8 months ago) by edhill
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -1 lines
change ignores

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
16 nc = netcdf([ fbname '_rot.nc' ],'write');
17 nxp1 = length( nc('Xp1') ); nx = nxp1 - 1;
18 nyp1 = length( nc('Yp1') ); ny = nyp1 - 1;
19 XCo = [];
20 XGo = [];
21 XCo = nc{'XC'}(:);
22 XGo = nc{'XG'}(:);
23 XC = XCo + rlon;
24 XG = XGo + rlon;
25 icp = find( XC(:) < -180.0 ); XC(icp) = XC(icp) + 360.0;
26 icm = find( XC(:) > 180.0 ); XC(icm) = XC(icm) - 360.0;
27 igp = find( XG(:) < -180.0 ); XG(icp) = XG(icp) + 360.0;
28 igm = find( XG(:) > 180.0 ); XG(icm) = XG(icm) - 360.0;
29 nc{'XC'}(:) = XC(:);
30 nc{'XG'}(:) = XG(:);
31
32 gid = fopen([ fbname '.mitgrid' ], 'r', 'ieee-be');
33 tmp = reshape(fread(gid,inf,'real*8',0,'ieee-be'),[nxp1*nyp1,16]);
34 XC = tmp(:,1) + rlon;
35 XG = tmp(:,6) + rlon;
36 icp = find( XC(:) < -180.0 ); XC(icp) = XC(icp) + 360.0;
37 icm = find( XC(:) > 180.0 ); XC(icm) = XC(icm) - 360.0;
38 igp = find( XG(:) < -180.0 ); XG(icp) = XG(icp) + 360.0;
39 igm = find( XG(:) > 180.0 ); XG(icm) = XG(icm) - 360.0;
40 tmp(:,1) = XC;
41 tmp(:,6) = XG;
42 fclose( gid );
43
44 gid = fopen([ fbname '_rot.mitgrid' ], 'w', 'ieee-be');
45 fwrite(gid,tmp,'real*8');
46 fclose( gid );
47
48 end
49

  ViewVC Help
Powered by ViewVC 1.1.22