function [pressland, jland] = landfallpress(lat, long, p, jmax)
%
% Determines central pressure on landfall using bathymetry data set.
%    Copyright 2020 WindRiskTech L.L.C.
%    Last modified October, 2020
%-------------------------------------------------------------------------
load bathymetry.mat bathy
bathy=min(bathy,200); 
%
[n,~]=size(p);
jland=zeros(1,n);
pressland=zeros(1,n);
%
for i=1:n
    hold=-1000;
    for j=1:jmax(i)
        if long(i,j) >= 360
            long(i,j)=long(i,j)-360;
        end    
        ib=1+floor(4*long(i,j));
        if ib > 1440
            ib=1;
        end    
        ibp=ib+1;
        if ibp > 1440
            ibp=1;
        end    
        jb=1+floor(4*(lat(i,j)+90));
        b1=bathy(ib,jb);
        b2=bathy(ib,jb+1);
        b3=bathy(ibp,jb);
        b4=bathy(ibp,jb+1);
        dely=1+4*(lat(i,j)+90)-jb;
        delx=1+4*long(i,j)-ib;
        d1=(1.-delx)*(1.-dely);
        d2=dely*(1.-delx);
        d3=delx*(1.-dely);
        d4=delx*dely;
        %h=-exp(d1.*log(-b1+220)+d2.*log(-b2+220)+d3.*log(-b3+220)+d4.*log(-b4+220))+220;
        h=d1*b1+d2*b2+d3*b3+d4*b4;
        if hold < 0 && h > 0
            jland(i)=j;
            jm=max(j-1,1);
            pressland(i)=p(i,jm);
        end   
        hold=h;
    end
end    