%Verion of gendata.m modified by Vero %This is a matlab script that generates the input data % the configuation approximately the ISOMIP experiment no. 1 % require matlab functions for equation of state % Dimensions of grid nx=30; ny=50; nz=100; delZ = 10; delz=10; dz=10; hfacMin = 0.2; dlat = 0.125/4; dy=dlat; dlon = 0.125; dx=dlon; %eos = 'linear'; eos = 'jmd95z'; % eos = 'mdjwf'; acc = 'real*8'; long = [-105.5:dlon:-99.375]; lonc = long+dlon/2; latg = [-75.4457:dlat:-74.5068-dlat]; latc = latg+dlat/2; size(latc) % Nominal depth of model (meters) H = -1000; %water depth in the ice shelf cavity Hmin = -900; % deepest point of cavern Hmax = -100; % shallowest point of cavern dHdy = (Hmax-Hmin)/(max(latg)-min(latc)); %Slope of ice shelf: if denominator = nx, shelf will cover the whole domain bathy = ones(nx,ny)*H; %For flat bathymetry: bathy = ones(nx,ny)*H; bathy(1,:) = 0; bathy(nx,:) = 0; bathy(:,1) = 0; %bathy(:,ny) = 0; fid=fopen('bathymetry.pig.bin','w','b'); fwrite(fid,bathy,acc);fclose(fid); dz = delZ*ones(1,nz); zgp1 = [0,cumsum(dz)]; zc = .5*(zgp1(1:end-1)+zgp1(2:end)); zg = zgp1(1:end-1); dz = diff(zgp1); sprintf('delZ = %d * %7.6g,',nz,dz) T_sfc = -1.9; T_bottom = 1.1967; del_T = (T_bottom - T_sfc)/((nz-1)*delZ); for iz = 1:nz; tref(iz) = T_sfc + del_T*((iz-1)*delZ); end S_sfc = 34.2050; S_bottom = 34.6967; del_S = (S_bottom - S_sfc)/((nz-1)*delZ); for iz = 1:nz; sref(iz) = S_sfc + del_S*((iz-1)*delZ); end % Gravity gravity=9.81; rhoConst = 1030; % compute potential field underneath ice shelf talpha = 2e-4; sbeta = 7.4e-4; % tref = -1.9*ones(nz,1); t = tref; % sref = 34.4*ones(nz,1); s = sref; gravity = 9.81; k=1; dzm = abs([zg(1)-zc(1) .5*diff(zc)]); dzp = abs([.5*diff(zc) zc(end)-zg(end)]); p = abs(zc)*gravity*rhoConst*1e-4; dp = p; kp = 0; while rms(dp) > 1e-13 phiHydF(k) = 0; p0 = p; kp = kp+1 for k = 1:nz switch eos case 'linear' drho = rhoConst*(1-talpha*(t(k)-tref(k))+sbeta*(s(k)-sref(k)))-rhoConst; case 'jmd95z' drho = densjmd95(s(k),t(k),p(k))-rhoConst; case 'mdjwf' drho = densmdjwf(s(k),t(k),p(k))-rhoConst; otherwise error(sprintf('unknown EOS: %s',eos)) end phiHydC(k) = phiHydF(k) + dzm(k)*gravity*drho/rhoConst; phiHydF(k+1) = phiHydC(k) + dzp(k)*gravity*drho/rhoConst; end switch eos case 'mdjwf' p = (gravity*rhoConst*abs(zc) + phiHydC*rhoConst)/gravity/rhoConst; end dp = p-p0; end %Modify icetopo (shape of ice shelf cavity) % %icetopo = ones(ny,1)*min(Hmin + 2*dHdy*(lonc(nx)-long),Hmax); % B=min(Hmin + 2*dHdy*(lonc(ny)-long),Hmax); % B=fliplr(B); % % icetopo = ones(nx,1)*B; % %icetopo = icetopo'; % icetopo(:,101:end)=0; % use streamice generated thickness fid = fopen('h_init.box','r','b'); hinit=fread(fid,[dy dx],'real*8'); fclose(fid); %hinit(:,1:5)=550; icetopo = -917/1028*hinit; %Modify icetopo (shape of ice shelf cavity) icetopo = ones(ny,1)*min(Hmax,Hmin + 2*dHdy*(lonc(nx)-long)); icetopo = icetopo'; icetopo(1:25,:)=0; % use streamice generated thickness fid = fopen('h_init.box','r','b'); hinit=fread(fid,[30 50],'real*8'); fclose(fid); %hinit(:,1:5)=550; icetopo = -917/1028*hinit; % adjust topo so that no hfac is smaller than hfacMin for ix=1:nx for iy=1:ny k=max(find(abs(zg)0 dr = -zg(k) - icetopo(ix,iy); if (dr>=delZ/2) phi0surf(ix,iy) = phiHydF(k) + (delZ-dr) * (phiHydC(k)-phiHydF(k))/(delZ/2); else phi0surf(ix,iy) = phiHydC(k) + (delZ/2-dr) * (phiHydF(k+1)-phiHydC(k))/(delZ/2); end end end end mass = phi0surf / gravity - rhoConst * icetopo; %use streamicegenerated thickness %mass = hinit * 917; fid = fopen('shelftopo.pig.bin','w','b'); fwrite(fid,icetopo,'real*8'); fclose(fid); fid = fopen('shelficemassinit.bin','w','b'); fwrite(fid,mass,'real*8'); fclose(fid); fid = fopen('pload.pig.jmd95z','w','b'); fwrite(fid,phi0surf,'real*8'); fclose(fid); etainit = zeros(size(phi0surf)); % new topography: icetopo rounded to the nearest k * deltaZ % eta_init set to make difference icetopo2 = icetopo; for ix=1:nx for iy=1:ny k=max(find(abs(zg) .5) % bring Ro_surf *up* to closest grid face & make etainit negative % to compensate icetopo2(ix,iy) = -zg(k); etainit(ix,iy) = (dr-1)*delz; else % bring Ro_surf *down* to closest grid face & make etainit pos % to compensate icetopo2(ix,iy) = -zg(k+1); etainit(ix,iy) = (dr)*delz; end end end end fid = fopen('shelftopo.round.bin','w','b'); fwrite(fid,icetopo2,'real*8'); fclose(fid); fid = fopen('etainit.round.bin','w','b'); fwrite(fid,etainit,'real*8'); fclose(fid);