;*************************************************** ; This program takes in the year month and day. It ; calculates the day of the year ;*************************************************** pro julian_date,year,month,day,juldate ;year=2007 ;month=4 ;day=13 ;****************************** ; Check if the year is a leap year ;****************************** leap_flag=0 ;not a leap year check4=(year) mod 4 ;years divisible by 4 are leap years, unless........... check100=(year) mod 100 ;years also divisible by 100 are not leap years, except....... check400=(year)mod 400 ;years divisible by 400 are leap years. if ( (check4 eq 0 and check100 ne 0) or (check400 eq 0) ) then leap_flag=1 ;leap year ;****************************** ; Make an array of the number of days ;****************************** if leap_flag eq 0 then begin ; J F M A M J J A S O N D num_days=[31,28,31,30,31,30,31,31,30,31,30,31] endif else if leap_flag eq 1 then begin num_days=[31,29,31,30,31,30,31,31,30,31,30,31] endif ; Sum up the months of days if month-2 ge 0 then juldate=total(num_days[0:month-2]) else juldate=0 ; Add on the extra days juldate=juldate+day ; Make it an integer juldate=fix(juldate) ;print,year,month,day ;print,juldate ;print,'leap_flag',leap_flag return end