function plot_fhi_psp(cpi,figid)
%
% plot_fhi_psp(cpi,[figid])
%
% Plot the pseudopotential in FHI98MD format.
%
%  cpi.[]
%	Zv, lmax
%	ngrid(:), clog(:),
%	RS(:), rPsiS(:), VionS(:),
%	RP(:), rPsiP(:), VionP(:),
%	RD(:), rPsiD(:), VionD(:),
%	core(:,1:4);   # r, 4pi*rho_c(r), (1st deriv), (2nd deriv)
%

if (nargin>1)
  figure(figid);
end

if (size(cpi.core,1))==cpi.ngrid
  has_core = 1;
  dy = 2;
else
  has_core = 0;
  dy = 1;
end

subplot(dy,2,1);
x = semilogx(cpi.RS,cpi.VionS, cpi.RP,cpi.VionP, cpi.RD,cpi.VionD);
legend(x, 's','p','d');

subplot(dy,2,2);
x = semilogx(cpi.RS,cpi.rPsiS, cpi.RP,cpi.rPsiP, cpi.RD,cpi.rPsiD);
legend(x, 's','p','d');

if has_core==1
  subplot(dy,2,3);
  semilogx(cpi.core(:,1),cpi.core(:,2));
end
