function [Profile] = p1d(x,nx,dx,dt,t,totaltime,LBC_TYPE,LBC,RBC_TYPE, ...
   RBC,vx,vz,kappa,ProfileInitCond,waithandle);  

simtime = dt;

x1 = x(1);
xend = x(end);

Profile = ProfileInitCond;

X = x;

while (simtime <= t)

  Qt = -kappa.*diff(Profile)./dx;
  
  % Apply Boundary Conditions:
 
  if(LBC_TYPE)
    LBCn = LBC;
  else
    LBCn = Qt(1);
    Profile(1) = LBC;
  end

  if(RBC_TYPE)
    RBCn = RBC;
  else
    RBCn = Qt(nx-1);
    Profile(nx) = RBC;
  end

  Qt = [LBCn,Qt,RBCn];
   
  % Compute dH:

  dH = dt.*(diff(Qt)./dx);
 
  %  Add Elevation Change to Profile with possibility of wl conditions:
  Profile = Profile - dH;

  % Add tectonic displacements to profile, x, and bedrock:

  x = x + vx.*dt;
  Profile = Profile + vz.*dt;

  %  Interpolate new profile:
  X(1) = x1;
  x(end) = xend;
  Profile = interp1(x,Profile,X,'linear');
  x = X;

  %  Increment time:

  if(((t-simtime) < dt) & ((t-simtime) > 0))
    dt = t-simtime;
  end

  simtime = simtime + dt;

  %  Update waitbox handle:
  waitbar(simtime./totaltime,waithandle);

end











