! Program Example from "Essential Fortran 90 & 95" by Loren P. Meissner
! Copyright 1996. Copying for sale requires permission from the author.
! Otherwise, distribution is permitted if these three lines are included.

! Example 3.17. Thirty days hath September...
  program D17
    implicit none
    integer :: Month, Year, NDays
! start program D17
    write (unit = *, fmt = *) " Please enter the year (4 digits). "
    read (unit = *, fmt = *) Year
    write (unit = *, fmt = *) " Please enter the month number (1 to 12). "
    read (unit = *, fmt = *) Month
    select case (Month)
      case (9, 4, 6, 11)  ! Sep, Apr, Jun, Nov
        NDays = 30
      case (2)  ! February
        if (modulo( Year, 4 ) == 0) then
          NDays = 29  !Leap year
        else
          NDays = 28
        end if
      case default  ! Jan, Mar, May, Jul, Aug, Oct, Dec
        NDays = 31
    end select
    write (unit = *, fmt = *) " The number of days in month: ", Month, " is: ", NDays
    stop
  end program D17
