;******************************************** ; This subroutine takes in the julian day of ; the year and the year and computes the ; corresponding month and day ;******************************************** pro day_of_year_to_date,doy,year,month,day ; Julian day of the year ;doy=365 ; Year ;year=2002 ;*********************************** ; Check to see if it is a leap year ;*********************************** check4=(year) mod 4 check100=(year) mod 100 check400=(year) mod 400 ; Leap year condition leap_flag='no' if ( (check4 eq 0 and check100 ne 0) or (check400 eq 0) ) then begin leap_flag='yes' ;print,'found leap year',year endif ;*********************************** ; Create arrays of the days in the months ;*********************************** if leap_flag eq 'no' then begin month_days=[31,28,31,30,31,30,31,31,30,31,30,31] endif else if leap_flag eq 'yes' then begin month_days=[31,29,31,30,31,30,31,31,30,31,30,31] endif ;*********************************** ; Determine the day and month ;*********************************** i=0 while doy gt month_days[i] do begin doy=doy-month_days[i] i=i+1 endwhile month=i+1 day=doy ;print,month,'month',day,'day' return end