/[MITgcm]/MITgcm_contrib/shelfice_remeshing/CPL1/input/gendata_vero.m
ViewVC logotype

Annotation of /MITgcm_contrib/shelfice_remeshing/CPL1/input/gendata_vero.m

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


Revision 1.1 - (hide annotations) (download)
Mon Oct 12 16:08:16 2015 UTC (9 years, 9 months ago) by dgoldberg
Branch: MAIN
CVS Tags: HEAD
new input files for coupled ex.

1 dgoldberg 1.1 %Verion of gendata.m modified by Vero
2     %This is a matlab script that generates the input data
3    
4    
5     % the configuation approximately the ISOMIP experiment no. 1
6     % require matlab functions for equation of state
7    
8    
9     % Dimensions of grid
10     nx=3;
11     ny=200;
12     nz=100;
13     delz = 10;
14    
15     hfacMin = 0.2;
16    
17     dlat = 0.125/16; dy=dlat;
18     dlon = 0.125/4; dx=dlon;
19    
20     %eos = 'linear';
21     eos = 'jmd95z';
22     % eos = 'mdjwf';
23    
24     acc = 'real*8';
25    
26     long = [-105.5:dlon:-105.5];
27     lonc = long+dlon/2;
28     latg = [-75.4457:dlat:-73.8809-dlat];
29     latc = latg+dlat/2;
30     size(latc)
31    
32     % Nominal depth of model (meters)
33     H = -1000; %water depth in the ice shelf cavity
34     Hmin = -900; % deepest point of cavern
35     Hmax = -300; % shallowest point of cavern
36     dHdy = (Hmax-Hmin)/(max(latc)-min(latc)); %Slope of ice shelf: if denominator = nx, shelf will cover the whole domain
37    
38     bathy = ones(nx,ny)*H; %For flat bathymetry: bathy = ones(nx,ny)*H;
39     %bathy(1,:) = 0;
40     %bathy(2,:) = 0;
41     %bathy(nx,:) = 0;
42     %bathy(nx-1,:) = 0;
43     bathy(:,1) = 0;
44     %bathy(:,ny) = 0;
45     fid=fopen('bathymetry.pig.bin','w','b'); fwrite(fid,bathy,acc);fclose(fid);
46    
47    
48     dz = delz*ones(1,nz);
49     zgp1 = [0,cumsum(dz)];
50     zc = .5*(zgp1(1:end-1)+zgp1(2:end));
51     zg = zgp1(1:end-1);
52     dz = diff(zgp1);
53     sprintf('delZ = %d * %7.6g,',nz,dz)
54    
55    
56     T_sfc = -1.9;
57     T_bottom = 2;
58     del_T = (T_bottom - T_sfc)/(59*delz);
59    
60     for iz = 1:nz;
61    
62    
63     tref(iz) = T_sfc + del_T*((iz-30)*delz);
64     if iz<=30;
65     tref(iz)=-1.9;
66     end
67     if iz>=90
68     tref(iz) =2;
69     end
70     end
71    
72     S_sfc = 34.2;
73     S_bottom = 34.7;
74     del_S = (S_bottom - S_sfc)/(59*delz);
75    
76     for iz = 1:nz;
77    
78    
79     sref(iz) = S_sfc + del_S*((iz-30)*delz);
80     if iz<=30;
81     sref(iz)=34.2;
82     end
83     if iz>=90
84     sref(iz) =34.7;
85     end
86     end
87    
88     % Gravity
89     gravity=9.81;
90     rhoConst = 1030;
91     % compute potential field underneath ice shelf
92     talpha = 2e-4;
93     sbeta = 7.4e-4;
94     % tref = -1.9*ones(nz,1);
95     t = tref;
96     % sref = 34.4*ones(nz,1);
97     s = sref;
98     gravity = 9.81;
99     k=1;
100     dzm = abs([zg(1)-zc(1) .5*diff(zc)]);
101     dzp = abs([.5*diff(zc) zc(end)-zg(end)]);
102     p = abs(zc)*gravity*rhoConst*1e-4;
103     dp = p;
104     kp = 0;
105    
106    
107    
108     while rms(dp) > 1e-13
109     phiHydF(k) = 0;
110     p0 = p;
111     kp = kp+1
112     for k = 1:nz
113     switch eos
114     case 'linear'
115     drho = rhoConst*(1-talpha*(t(k)-tref(k))+sbeta*(s(k)-sref(k)))-rhoConst;
116     case 'jmd95z'
117     drho = densjmd95(s(k),t(k),p(k))-rhoConst;
118     case 'mdjwf'
119     drho = densmdjwf(s(k),t(k),p(k))-rhoConst;
120     otherwise
121     error(sprintf('unknown EOS: %s',eos))
122     end
123     phiHydC(k) = phiHydF(k) + dzm(k)*gravity*drho/rhoConst;
124     phiHydF(k+1) = phiHydC(k) + dzp(k)*gravity*drho/rhoConst;
125     end
126     switch eos
127     case 'mdjwf'
128     p = (gravity*rhoConst*abs(zc) + phiHydC*rhoConst)/gravity/rhoConst;
129     end
130     dp = p-p0;
131     end
132    
133    
134     %Modify icetopo (shape of ice shelf cavity)
135    
136     %icetopo = ones(ny,1)*min(Hmin + 2*dHdy*(lonc(nx)-long),Hmax);
137     B=min(Hmin + 2*dHdy*(latc(ny)-latg),Hmax);
138     B=fliplr(B);
139    
140     icetopo = ones(nx,1)*B;
141     %icetopo = icetopo';
142     icetopo(:,101:end)=0;
143    
144     % use streamice generated thickness
145     fid = fopen('h_init.box','r','b'); hinit=fread(fid,[3 200],'real*8'); fclose(fid);
146     %hinit(:,1:5)=550;
147     icetopo = -917/1028*hinit;
148    
149    
150     % adjust topo so that no hfac is smaller than hfacMin
151    
152     for ix=1:nx
153     for iy=1:ny
154     k=max(find(abs(zg)<abs(icetopo(ix,iy))));
155    
156     if(~isempty(k))
157    
158    
159     hfacTemp = (icetopo(ix,iy) - (-zg(k+1)))/delz;
160    
161     if (hfacTemp < hfacMin)
162     if (hfacTemp < hfacMin/2)
163     hfacTemp = 0;
164     else
165     hfacTemp = hfacMin;
166     end
167     end
168    
169     else
170    
171     hfacTemp = 0;
172    
173     end
174    
175     icetopo(ix,iy) = icetopo(ix,iy) + hfacTemp;
176    
177     end
178     end
179    
180     % phi anomaly (relative to hydrostatic with rho_const) at icetopo
181    
182     phi0surf = zeros(nx,ny);
183    
184     for ix=1:nx
185     for iy=1:ny
186     k=max(find(abs(zg)<abs(icetopo(ix,iy))));
187     if isempty(k)
188     k=0;
189     end
190     if k>0
191    
192     dr = -zg(k) - icetopo(ix,iy);
193    
194     if (dr>=delz/2)
195     phi0surf(ix,iy) = phiHydF(k) + (delz-dr) * (phiHydC(k)-phiHydF(k))/(delz/2);
196     else
197     phi0surf(ix,iy) = phiHydC(k) + (delz/2-dr) * (phiHydF(k+1)-phiHydC(k))/(delz/2);
198     end
199    
200     end
201     end
202     end
203    
204     mass = phi0surf / gravity - rhoConst * icetopo;
205    
206     %use streamicegenerated thickness
207    
208     %mass = hinit * 917;
209    
210     fid = fopen('shelftopo.pig.bin','w','b'); fwrite(fid,icetopo,'real*8'); fclose(fid);
211     fid = fopen('shelficemassinit.bin','w','b'); fwrite(fid,mass,'real*8'); fclose(fid);
212     fid = fopen('pload.pig.jmd95z','w','b'); fwrite(fid,phi0surf,'real*8'); fclose(fid);
213    
214     etainit = zeros(size(phi0surf));
215    
216     % new topography: icetopo rounded to the nearest k * deltaZ
217     % eta_init set to make difference
218    
219     icetopo2 = icetopo;
220    
221     for ix=1:nx
222     for iy=1:ny
223     k=max(find(abs(zg)<abs(icetopo2(ix,iy))));
224     if isempty(k)
225     k=0;
226     else
227    
228     dr = 1-(-zg(k) - icetopo2(ix,iy))/delz;
229     if (dr > .5)
230     % bring Ro_surf *up* to closest grid face & make etainit negative
231     % to compensate
232     icetopo2(ix,iy) = -zg(k);
233     etainit(ix,iy) = (dr-1)*delz;
234     else
235     % bring Ro_surf *down* to closest grid face & make etainit pos
236     % to compensate
237     icetopo2(ix,iy) = -zg(k+1);
238     etainit(ix,iy) = (dr)*delz;
239     end
240    
241     end
242     end
243     end
244    
245     fid = fopen('shelftopo.round.bin','w','b'); fwrite(fid,icetopo2,'real*8'); fclose(fid);
246     fid = fopen('etainit.round.bin','w','b'); fwrite(fid,etainit,'real*8'); fclose(fid);

  ViewVC Help
Powered by ViewVC 1.1.22