function rjul = dmy2rd(day,mon,yr)
%
%function rjul = dmy2rd(day,month,yr)
%
%     converts (day, month, year) to RAFOS JULIAN day (rjul)
%     RAFOS JULIAN day = julian day (ref. to 24 nov 4713BC) - 2440000
%
%          translated from dates.c from GSO RAFOS processing code
%          which was taken from Collected Algorithms from ACM, #199
%                   "astronomically correct"
%          and converted to RAFOS JULIAN day   20.03.91 kst
%          This routine is valid forever ....
%
%   NOTE:  this RAFOS JULIAN day = old ARGOS day - 6718 + 1

if (nargin == 1)
  d = day;
  day = d(:,1);
  mon = d(:,2);
  yr = d(:,3);
end
day = day(:);  mon = mon(:);  yr = yr(:);

gttwo = find( mon > 2 );
letwo = find( mon < 3 );
mon(gttwo) = mon(gttwo) - 3;
mon(letwo) = mon(letwo) + 9;
yr(letwo) = yr(letwo) - 1;

ic = floor( yr / 100 );
iy = yr - 100*ic;
rjul = floor((146097*ic)/4) + floor((1461*iy)/4) + floor((153*mon+2)/5) ...
    + day + 1721119;

% rjul = rjul - 2440000;
% OB redefined rafos day, to shorten numbers
rjul = rjul - 2451545;