function [jday] = julian( year, month, day )
% this script is the inverse of julian()
% return the julian day given the year, month and day
%
% input:
%        year, an integer, e.g. 2010
%        month, an integer, with January being 1
%        day, an integer, with the first day of the month being 1
%
% output:
%        jday, an integer, the julian day of the year, with Jan 1 being 1
%
daysinmonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
leap = isleap(year);
jday=0;
if ( month>1 )
    for i = [1:month-1]
        jday=jday+daysinmonth(i);
        if( leap && (i==2) )
            jday=jday+1;
        end
    end
end
jday = jday + day;
return;
