Warning, /verification/dome/input/gendata.m is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit 00816bc2 on 2004-07-06 18:40:33 UTC
00816bc2b8 Alis*0001 % This is a matlab script that generates the input data
0002 % variable x resolution
0003 prec='real*8';
0004 ieee='b';
0005
0006 % Dimensions of grid
0007 %nx=50;
0008 nx=200;
0009 ny=45;
0010 nz=25;
0011 % Nominal depth of model (meters)
0012 H=3600.0;
0013 % Size of domain
0014 Ly=600.0e3;
0015 %Lx=500.0e3;
0016 Lx=2000.0e3;
0017
0018 % Horizontal resolution (m)
0019
0020 dx=zeros(nx,1);
0021 for i=1:nx
0022 dx(i) = Lx/(nx);
0023 end
0024
0025 dy=zeros(ny,1);
0026 %for i=1:ny
0027 %dy(i) = Ly/(ny);
0028 %end
0029
0030 % y-resolution ramps from 10km to 40km in southern basin:
0031 y = [0:600];
0032 y0 = 420; yw = 40; r1 = 10; r2 = 40;
0033 dy = (r1+r2)/2 - (r1-r2)/2*tanh((y-y0)/yw);
0034
0035 yg = 0; ii = 1; dely = dy(1);
0036 while yg(ii)<=max(y)-dely,
0037 dely = interp1(y,dy,yg(ii));
0038 yg(ii+1) = yg(ii) + dely;
0039 ii = ii+1;
0040 end
0041 yg(ii) = max(y);
0042
0043 %plot(yg,mean(dy),'b+'); hold on;
0044 %plot(0.5*(yg(1:end-1)+yg(2:end)),diff(yg),'rx-');
0045 %plot(y,dy,'c.-'); grid on
0046 %pause
0047 dy = fliplr(diff(yg)*1e3);
0048
0049 dz=zeros(nz,1);
0050 for i=1:nz
0051 dz(i)=H/nz;
0052 end
0053 %sprintf('delZ = %d * %7.6g,',nz,dz)
0054
0055 z=zeros(nz,1);
0056 z(1) = -dz(1)/2.0;
0057 for i=2:nz
0058 z(i)=z(i-1) - dz(i);
0059 end
0060
0061 % Stratification
0062 gravity=9.81;
0063 talpha=2.0e-4;
0064 rho0=1030.0;
0065 rhotop=1030.0;
0066 %rhobot=1030.0;
0067 rhobot=1032.0;
0068
0069 %gravity=10;
0070 %talpha=1.0e-4;
0071 %rho0=1000.0;
0072 %rhotop=1000.0;
0073 %rhobot=1000.0;
0074 N2=((rhobot-rhotop)/H)/rho0*gravity
0075 Tz=N2/(gravity*talpha) ;
0076
0077 % Temperature profile. tRef is a single reference temperature, Tbg is
0078 % a background profile, t is a three-dimensional initial stratification.
0079 tRef = 0;
0080 %Tref=Tz*(z+H) + (rhobot-rho0)/(rho0*talpha) + 1.0;
0081 %Tref=Tz*(z+H) + (rhobot-rho0)/(rho0*talpha)
0082 Tbg =Tz*(z+H) - (rhobot-rho0)/(rho0*talpha) + tRef;
0083 [sprintf('Tref =') sprintf(' %8.6g,',Tbg)]
0084 %t=0.00001*rand([nx,ny,nz]);
0085 t=0*rand([nx,ny,nz]);
0086 for k=1:nz
0087 t(:,:,k) = t(:,:,k) + Tbg(k);
0088 end
0089 fid=fopen('T.init','w',ieee); fwrite(fid,t,prec); fclose(fid);
0090
0091 % this could be done more elegantly...
0092 x=zeros(nx,1);
0093 x(1) = 0.5*dx(1); % center of grid cell
0094 for i=2:nx
0095 x(i)=x(i-1) + 0.5*dx(i-1) + 0.5*dx(i);
0096 end
0097
0098 y=zeros(ny,1);
0099 y(1) = dy(1); % north edge of grid cell
0100 for i=2:ny
0101 y(i) = y(i-1) + dy(i);
0102 end
0103
0104 % Linear slope and embayment
0105 slope = 0.01;
0106 %slope = 0.005;
0107 lembay=50.0e3; % length of embayment
0108 eastwall = 1; % make a wall on the eastern boundary
0109 westwall = 0; % make a wall on the western boundary
0110
0111 % These three parameters should match with Width, Dmax and Xcenter
0112 % (respectively) in data.obcs or else funny stuff will happen...
0113 wembay=100.0e3; % width of embayment
0114 dembay=600.0; % depth of embayment
0115 embay_ctr=1700.0e3; % x-coordinate of embayment center
0116
0117 %xembay=Lx-150.0e3-wembay; %x location of start of embayment
0118 xembay=embay_ctr-wembay/2;
0119 d=0.0*rand([nx,ny]);
0120 for i=1:nx
0121 d(:,1) = 0.0;
0122 for j=2:ny
0123 yneg=Ly-y(j);
0124 if yneg < lembay
0125 if x(i) > xembay
0126 if x(i) < xembay+wembay
0127 d(i,j) = -dembay;
0128 else
0129 d(i,j) = 0.0;
0130 end
0131 else
0132 d(i,j) = 0.0;
0133 end
0134 else
0135 d(i,j) = -slope*(yneg - lembay) - dembay;
0136 end
0137 if d(i,j) < -H
0138 d(i,j) = -H;
0139 end
0140 end
0141 end
0142 if eastwall
0143 d(nx,:) = 0.0; % east wall
0144 end
0145 if westwall
0146 d(1,:) = 0.0; % west wall
0147 end
0148 fid=fopen('topog.slope','w',ieee); fwrite(fid,d,prec); fclose(fid);
0149 hold off;
0150 plot(x,d(:,2),'.-'); grid on
0151 %plot(y,d(2,:),'.-'); grid on
0152
0153 %fid=fopen('delXvar','w',ieee); fwrite(fid,dx,prec); fclose(fid);
0154 fid=fopen('delYvar','w',ieee); fwrite(fid,dy,prec); fclose(fid);