/[MITgcm]/MITgcm/utils/cs_grid/rotate_csAg_EN.m
ViewVC logotype

Contents of /MITgcm/utils/cs_grid/rotate_csAg_EN.m

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


Revision 1.2 - (show annotations) (download)
Thu Aug 18 18:26:15 2005 UTC (18 years, 11 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint57r_post, checkpoint57q_post
Changes since 1.1: +7 -5 lines
changes for 2.D or 4.D input arrays.

1 function [uE,vN] = rotate_csAg_EN(u,v)
2 % [uE,vN] = rotate_csAg_EN(u,v)
3 %
4 % Rotate U,V vector components of cs-grid (A-grid) to East,North directions
5 % u,v is a 2-D or 3-D horizontal components of a flow fields.
6 % uE,vN are the Eastward,Northward components of the rotated flow field
7 % assume that the 1rst 2 dimensions of (u,v) are [6*nc nc] for a CS(nc x nc) grid
8 %
9 % $Header: /u/gcmpack/MITgcm/utils/cs_grid/rotate_csAg_EN.m,v 1.1 2005/06/28 02:34:54 jmc Exp $
10
11 %Rac='/home/jmc/grid_cs32/' ;
12 Rac='grid_files/';
13
14 NN=size(u);
15 if length(NN) < 3, nz=1;
16 else nz=prod(NN(3:end));
17 end
18 nnx=NN(1); nc=NN(2); nPg=nnx*nc;
19 if nnx ~= 6*nc,
20 fprintf('Error in CS-dim: %i %i %i \n',NN);
21 return
22 end
23
24 u=reshape(u,[nPg nz]);
25 v=reshape(v,[nPg nz]);
26
27 %- rotate toward E,N (lon,lat) directions :
28 % load COS & SIN of rotation angle:
29 namfil=['proj_cs',int2str(nc),'_2uEvN.bin'];
30 fid=fopen([Rac,namfil],'r','b'); uvEN=fread(fid,nPg*2,'real*8'); fclose(fid);
31 uvEN=reshape(uvEN,[nPg 2]);
32
33 uE=zeros(nPg,nz); vN=zeros(nPg,nz);
34 for k=1:nz;
35 uE(:,k)=uvEN(:,1).*u(:,k)-uvEN(:,2).*v(:,k);
36 vN(:,k)=uvEN(:,2).*u(:,k)+uvEN(:,1).*v(:,k);
37 end
38
39 uE=reshape(uE,NN);
40 vN=reshape(vN,NN);
41
42 return

  ViewVC Help
Powered by ViewVC 1.1.22