function [V,C,H]=ice_remap(v,c,h); %(Lipscomb's approach using linear distributions; simplified.) % %object: remap ice categories after thermodynamical ice growth/melt % (v increments) may result in ice categories outgrowing % their limits ( v/c>h(n) or v/cC or dV0>V and ultimately to negative values tmp1=V(2:end-1,:); tmp2=C(2:end-1,:); ii=find(HL1=HL0|c1==0|v1==0); dC0(ii)=0; dV0(ii)=0; %1.3) time step V and C: V(2:end-1,:)=V(2:end-1,:)-dV0; V(1:end-2,:)=V(1:end-2,:)+dV0; C(2:end-1,:)=C(2:end-1,:)-dC0; C(1:end-2,:)=C(1:end-2,:)+dC0; %2) recast to thicker categories %=============================== %2.1) compute integrals between HR0 and HR1, which % will be transfered to the next category dC1=(g0-g1.*HL1).*(HR1-HR0)+1/2*g1.*(HR1.^2-HR0.^2); dV1=1/2*(g0-g1.*HL1).*(HR1.^2-HR0.^2)+1/3*g1.*(HR1.^3-HR0.^3); %avoid leaving exponentially small numbers : full recasting tmp1=V(2:end-1,:); tmp2=C(2:end-1,:); ii=find(tmp1<1e-4|tmp2<1e-4); dV1(ii)=tmp1(ii); dC1(ii)=tmp2(ii); %avoid category jump (HR1>HR0-dh) that leads to %dC0>C or dV0>V and ultimately to negative values tmp1=V(2:end-1,:); tmp2=C(2:end-1,:); ii=find(HR1>HR0+dh); dV0(ii)=tmp1(ii); dC0(ii)=tmp2(ii); %2.2) mask out points where no remapping ii=find(HR1<=HR0|c1==0|v1==0); dC1(ii)=0; dV1(ii)=0; %2.3) time step V and C: V(2:end-1,:)=V(2:end-1,:)-dV1; V(3:end,:)=V(3:end,:)+dV1; C(2:end-1,:)=C(2:end-1,:)-dC1; C(3:end,:)=C(3:end,:)+dC1;