| 1 | 
format compact | 
| 2 | 
path('/u/u0/dimitri/matlab/tools',path); | 
| 3 | 
path('/u/u0/dimitri/matlab/whoi',path); | 
| 4 | 
path('/u/u0/dimitri/matlab/mitgcm',path); | 
| 5 | 
path('/u/adcroft/matlab/bin',path); | 
| 6 | 
 | 
| 7 | 
nx=30; | 
| 8 | 
 | 
| 9 | 
%for typ={'conf','q=0','q=1','q=1/2','q=7/8','q=i3','tan','tan2','new'} | 
| 10 | 
 | 
| 11 | 
for typ={'tan'} | 
| 12 | 
 | 
| 13 | 
[dxg,dyg,dxf,dyf,dxc,dyc,dxv,dyu,Ec,Eu,Ev,Ez,latC,lonC,latG,lonG,... | 
| 14 | 
 Q11,Q22,Q12, TUu,TUv,TVu,TVv ]=gengrid_fn(nx+1,16,typ{1},'c',0,1); | 
| 15 | 
theta=zeros(nx/2,nx/2); | 
| 16 | 
for i=1:nx/2, for j=1:nx/2 | 
| 17 | 
  lat=[latG(i,j) latG(i+1,j)]*180/pi; | 
| 18 | 
  lon=[lonG(i,j) lonG(i+1,j)]*180/pi; | 
| 19 | 
  a=dist(lat,lon,'sphere'); | 
| 20 | 
  lat=[latG(i,j) latG(i,j+1)]*180/pi; | 
| 21 | 
  lon=[lonG(i,j) lonG(i,j+1)]*180/pi; | 
| 22 | 
  b=dist(lat,lon,'sphere'); | 
| 23 | 
  lat=[latG(i+1,j) latG(i,j+1)]*180/pi; | 
| 24 | 
  lon=[lonG(i+1,j) lonG(i,j+1)]*180/pi; | 
| 25 | 
  c=dist(lat,lon,'sphere'); | 
| 26 | 
  theta(i,j)=acos((a^2+b^2-c^2)/2/a/b); | 
| 27 | 
end, end | 
| 28 | 
disp(typ{1}) | 
| 29 | 
disp(minmax(dxg*6371)) | 
| 30 | 
disp(minmax(dxg(1:nx/2,1:nx/2)./dyg(1:nx/2,1:nx/2))) | 
| 31 | 
tmp=theta*180/pi; tmp(1,1)=nan; | 
| 32 | 
disp(minmax(tmp)) | 
| 33 | 
mypcolor(theta*180/pi); colorbar | 
| 34 | 
title(typ{1}) | 
| 35 | 
tmp=typ{1}; tmp(strfind(tmp,'/'))='_'; | 
| 36 | 
eval(['print -dpsc FIG' tmp]) | 
| 37 | 
 | 
| 38 | 
end | 
| 39 | 
 | 
| 40 | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 41 | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 42 | 
 | 
| 43 | 
clear all, close all, nx=30; genx; | 
| 44 | 
PN='/u/u0/dimitri/cubed_sphere/cs-tan-c-30-480/'; | 
| 45 | 
 | 
| 46 | 
LONG=zeros(nx,6,nx); LATG=zeros(nx,6,nx); | 
| 47 | 
for i=1:6 | 
| 48 | 
 tmp=readbin([PN 'LONG.' myint2str(i,3) '.bin'],[nx+1 nx+1],1,'real*8'); | 
| 49 | 
 LONG(:,i,:)=tmp(1:nx,1:nx); | 
| 50 | 
 tmp=readbin([PN 'LATG.' myint2str(i,3) '.bin'],[nx+1 nx+1],1,'real*8'); | 
| 51 | 
 LATG(:,i,:)=tmp(1:nx,1:nx); | 
| 52 | 
end | 
| 53 | 
writebin([PN 'LONG.bin'],LONG,1,'real*8'); | 
| 54 | 
writebin([PN 'LATG.bin'],LATG,1,'real*8'); | 
| 55 | 
 | 
| 56 | 
LONC=zeros(nx,6,nx); LATC=zeros(nx,6,nx); | 
| 57 | 
for i=1:6 | 
| 58 | 
 LONC(:,i,:)=readbin([PN 'LONC.' myint2str(i,3) '.bin'],[nx nx],1,'real*8'); | 
| 59 | 
 LATC(:,i,:)=readbin([PN 'LATC.' myint2str(i,3) '.bin'],[nx nx],1,'real*8'); | 
| 60 | 
end | 
| 61 | 
writebin([PN 'LONC.bin'],LONC,1,'real*8'); | 
| 62 | 
writebin([PN 'LATC.bin'],LATC,1,'real*8'); | 
| 63 | 
 | 
| 64 | 
for nm={'DXC','DYC','DXF','DYF','DXG','DYG','DXV','DYU','RA','RAS','RAW','RAZ'} | 
| 65 | 
 fld=tile_fld(PN,nm{1},nx); | 
| 66 | 
 writebin([PN nm{1} '.bin'],fld,1,'real*8'); | 
| 67 | 
 fld=[PN nm{1} '.bin']; plotfld, title([PN nm{1}]), pause | 
| 68 | 
end | 
| 69 | 
 | 
| 70 | 
 | 
| 71 | 
 | 
| 72 | 
 | 
| 73 | 
 | 
| 74 | 
nm='DXC'; fld=tile_fld(PN,nm,nx); | 
| 75 | 
writebin([PN nm '.bin'],fld,1,'real*8'); | 
| 76 | 
subplot(211), fld=[PN nm '.bin']; plotfld, title(nm) | 
| 77 | 
nm='DYC'; fld=tile_fld(PN,nm,nx); | 
| 78 | 
writebin([PN nm '.bin'],fld,1,'real*8'); | 
| 79 | 
subplot(212), fld=[PN nm '.bin']; plotfld, title(nm) | 
| 80 | 
 | 
| 81 | 
 | 
| 82 | 
 | 
| 83 | 
mypcolor(squeeze(DYC(:,1,:))); colorbar | 
| 84 | 
 | 
| 85 | 
DXF=tile_fld(PN,'DXF',nx); | 
| 86 | 
writebin([PN 'DXF.bin'],DXF,1,'real*8'); | 
| 87 | 
mypcolor(squeeze(DXF(:,1,:))); colorbar | 
| 88 | 
 | 
| 89 | 
DYF=tile_fld(PN,'DYF',nx); | 
| 90 | 
writebin([PN 'DYF.bin'],DYF,1,'real*8'); | 
| 91 | 
mypcolor(squeeze(DYF(:,1,:))); colorbar | 
| 92 | 
 | 
| 93 | 
DXG=tile_fld(PN,'DXG',nx); | 
| 94 | 
writebin([PN 'DXG.bin'],DXG,1,'real*8'); | 
| 95 | 
mypcolor(squeeze(DXG(:,1,:))); colorbar | 
| 96 | 
 | 
| 97 | 
DYG=tile_fld(PN,'DYG',nx); | 
| 98 | 
writebin([PN 'DYG.bin'],DYG,1,'real*8'); | 
| 99 | 
mypcolor(squeeze(DYG(:,1,:))); colorbar | 
| 100 | 
 | 
| 101 | 
DXV=tile_fld(PN,'DXV',nx); | 
| 102 | 
writebin([PN 'DXV.bin'],DXV,1,'real*8'); | 
| 103 | 
mypcolor(squeeze(DXV(:,1,:))); colorbar | 
| 104 | 
 | 
| 105 | 
DYU=tile_fld(PN,'DYU',nx); | 
| 106 | 
writebin([PN 'DYU.bin'],DYU,1,'real*8'); | 
| 107 | 
mypcolor(squeeze(DYU(:,1,:))); colorbar | 
| 108 | 
 | 
| 109 | 
RA=tile_fld(PN,'RA',nx); | 
| 110 | 
writebin([PN 'RA.bin'],RA,1,'real*8'); | 
| 111 | 
mypcolor(squeeze(RA(:,1,:))); colorbar | 
| 112 | 
 | 
| 113 | 
RAS=tile_fld(PN,'RAS',nx); | 
| 114 | 
writebin([PN 'RAS.bin'],RAS,1,'real*8'); | 
| 115 | 
mypcolor(squeeze(RAS(:,1,:))); colorbar | 
| 116 | 
 | 
| 117 | 
RAW=tile_fld(PN,'RAW',nx); | 
| 118 | 
writebin([PN 'RAW.bin'],RAW,1,'real*8'); | 
| 119 | 
mypcolor(squeeze(RAW(:,1,:))); colorbar | 
| 120 | 
 | 
| 121 | 
RAZ=tile_fld(PN,'RAZ',nx); | 
| 122 | 
writebin([PN 'RAZ.bin'],RAZ,1,'real*8'); | 
| 123 | 
mypcolor(squeeze(RAZ(:,1,:))); colorbar |