!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!i!!!!!!!!!!!!!!!!!!!!!!!!!! !!! Subroutine for inter-conversion of Calendar and Julian Days !!! !!! Forward Conversion: Calendar Day to Julian Day !!! !!! Reverse Conversion: Julian Day to Calendar Day !!! !!! Version: March 24, 2010 (ATJ/DBS) !!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! idd = date (Can be anything between 1 to 31) ! imo = month (Can be anything between 1 to 12) ! iyr = year (Can be literally anything) ! jday = julian day number (Can be anything between 1 to 366) ! iflag = 1 for forward; -1 for reverse Subroutine cal_jul_cal (iddd,immm,iyyy,julday,iflag) Dimension incmon(13), leapinc(13) Data incmon /0, 31, 59, 90, 120, 151, 181, 212, & & 243, 273, 304, 334, 365/ Data leapinc /0, 31, 60, 91, 121, 152, 182, 213,& & 244, 274, 305, 335, 366/ icheck = mod (iyyy, 4) ! icheck is leap year checking index !* icheck = 0, if the current year is not a leap year !* icheck = 1, if the current year is a leap year If (iflag == 1) Go to 101 If (iflag ==-1) Go to 102 101 Continue If (icheck /= 0) julday = iddd + incmon(immm) If (icheck == 0) julday = iddd + leapinc(immm) Go to 110 102 Continue If (icheck /= 0) then Do i = 1, 12 j = i + 1 if ( (julday > incmon(i)).and.(julday <= incmon(j)) ) & & immm = i if ( (julday > incmon(i)).and.(julday <= incmon(j)) ) & & iddd = julday-incmon(i) Enddo Else Do i = 1, 12 j = i + 1 if ( (julday > leapinc(i)).and.(julday <= leapinc(j)) ) & & immm = i if ( (julday > leapinc(i)).and.(julday <= leapinc(j)) ) & & iddd = julday-leapinc(i) Enddo Endif Go to 110 110 Return End