subroutine jday(imon, iday, iyear, julday) ! This routine calculates the Julian day (julday) from ! the month (imon), day (iday), and year (iyear). The ! appropriate correction is made for leap year. ! Modifications: ! 4/20/21 (J. Dostalek) Started this Fortran 90 version !------------------------------------------------------------------------------- implicit none integer, intent(in) :: imon integer, intent(in) :: iday integer, intent(in) :: iyear integer, intent(out) :: julday integer :: i integer, dimension(12) :: ndmon ! Specify the number of days in each month ndmon(1) = 31 ndmon(2) = 28 ndmon(3) = 31 ndmon(4) = 30 ndmon(5) = 31 ndmon(6) = 30 ndmon(7) = 31 ndmon(8) = 31 ndmon(9) = 30 ndmon(10) = 31 ndmon(11) = 30 ndmon(12) = 31 ! Correct for leap year if (mod(iyear, 4) == 0) ndmon(2) = 29 if (mod(iyear, 100) == 0) ndmon(2) = 28 if (mod(iyear, 400) == 0) ndmon(2) = 29 ! Check for illegal input if (imon < 1 .or. imon > 12) then julday = -1 return end if if (iday < 1 .or. iday > ndmon(imon)) then julday = -1 return end if ! Calculate the Julian day julday = iday if (imon > 1) then do i = 2, imon julday = julday + ndmon(i - 1) end do end if return end subroutine jday