/[MITgcm]/MITgcm_contrib/dfer/cpl_aim+ocn_fast/input_ocn/modif_grid.m
ViewVC logotype

Annotation of /MITgcm_contrib/dfer/cpl_aim+ocn_fast/input_ocn/modif_grid.m

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


Revision 1.1 - (hide annotations) (download)
Thu Jan 6 16:40:24 2011 UTC (14 years, 7 months ago) by dfer
Branch: MAIN
CVS Tags: HEAD
New C24 grid files fixed by JMC (--> fix restart if no optimization)

1 dfer 1.1
2     kwr=1;
3     nc=24;
4     np=nc+1; n6x=6*nc; nPg=n6x*nc;
5     addAngle=1;
6    
7     outpName='grid_cs24';
8     inpName='tile.mitgrid';
9     rDir='./';
10    
11     for n=1:6,
12     %-- read :
13     p=strfind(inpName,'.mitgrid');
14     if isempty(p),
15     namF=sprintf([rDir,inpName,'.face%3.3i.bin'],n);
16     else
17     namF=sprintf([rDir,inpName(1:4),'%3.3i',inpName(5:end)],n);
18     end
19     fid=fopen(namF,'r','b');
20     vv1=fread(fid,'real*8');
21     fclose(fid);
22     s=size(vv1,1); k1=s/np/np;
23     fprintf(['read: ',namF,' : size: %i (%ix%ix%i)\n'],s,np,np,k1);
24     vv1=reshape(vv1,[np np k1]);
25     %--- save each face:
26     if n == 1,
27     vvf=zeros(np,np,6,k1);
28     end
29     vvf(:,:,n,:)=vv1;
30     %-- fix missing corner values :
31     if mod(n,2) == 1, i=1; j=np; else i=np; j=1; end
32     %- xG k= 6 : Corner Max diff m1 = 1.42109e-14 (f3,f5= 1.42109e-14 -7.10543e-15)
33     if n == 3 | n == 5,
34     k=6;
35     vvf(i,j,n,k)=vvf(i,j,1,k);
36     end
37     %- yG k= 7 : Corner Max diff m2 = 7.10543e-15 (f4,f6= 0 7.10543e-15)
38     if n == 6,
39     k=7;
40     vvf(i,j,n,k)=vvf(i,j,2,k);
41     end
42     end
43    
44     %- XC YC DXF DYF RA XG YG DXV DYU RAZ DXC DYC RAW RAS DXG DYG:
45     if addAngle == 1,
46     %-- Compute angle:
47     var=vvf(1:nc,1:nc,:, 7); var=reshape(permute(var,[1 3 2]),[nPg 1]);
48     yG =zeros(nPg+2,1); yG(1:nPg,1)=var;
49     yG(nPg+1,1)=vvf(1,np,1,7); yG(nPg+2,1)=vvf(np,1,2,7);
50     var=vvf(1:nc,1:nc,:, 5); rAc=reshape(permute(var,[1 3 2]),[n6x nc]);
51     var=vvf(1:nc,1:nc,:,15); dxG=reshape(permute(var,[1 3 2]),[n6x nc]);
52     var=vvf(1:nc,1:nc,:,16); dyG=reshape(permute(var,[1 3 2]),[n6x nc]);
53    
54     [anCs,anSn] = cubeCalcAngle(yG,rAc,dxG,dyG);
55     anCs=permute(reshape(anCs,[nc 6 nc]),[1 3 2]);
56     anSn=permute(reshape(anSn,[nc 6 nc]),[1 3 2]);
57     end
58    
59     if kwr == 1,
60     %-- write to file:
61     for n=1:6,
62     if addAngle == 1,
63     %-- Add angle:
64     k2=k1+2;
65     vv2=zeros(np,np,k2); vv2(:,:,[1:k1])=vvf(:,:,n,:);
66     vv2([1:nc],[1:nc],k1+1)=anCs(:,:,n);
67     vv2([1:nc],[1:nc],k1+2)=anSn(:,:,n);
68     else
69     %-- do not add angle:
70     vv2=vvf(:,:,n,:);
71     end
72     namW=sprintf([outpName,'.face%3.3i.bin'],n);
73     fid=fopen(namW,'w','b');
74     fwrite(fid,vv2,'real*8');
75     fclose(fid);
76     fprintf([' write to file: ',namW,' %i 2D.var(%ix%i)\n'],k2,np,np);
77     end
78     end
79    

  ViewVC Help
Powered by ViewVC 1.1.22