!-----------------------------------------------------------------------
!
!  dow.f90
!
!  demo of the day_of_week subroutine
!
!-----------------------------------------------------------------------

program dow

  use utilities
  use timing

  implicit none

  character(64) :: year_str, month_str, day_str
  integer :: year, month, day
  character(3), dimension(7) :: day_array = &
                (/ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' /)

  integer :: iargc
  external   getarg

  if ( iargc() .ne. 3 ) then
    write(0,*) 'usage: dow <month> <day> <year>'
    stop
  end if

  call getarg(1, month_str)
  call getarg(2, day_str)
  call getarg(3, year_str)
  month = s2i(month_str)
  day = s2i(day_str)
  year = s2i(year_str)

  write(0,*) day_array(day_of_week(month, day, year))

end program dow
