program test1
implicit none
integer :: year, month

integer :: s_year, s_month, s_day, s_hour, s_min, duration

  year = 2010; month = 3

call setparam( year, month, s_year, s_month, s_day, s_hour, s_min, duration )

write(*,*)  year, month
write(*,*) s_year, s_month, s_day, duration


end


subroutine setparam( year, month, s_year, s_month, s_day, s_hour, s_min, duration )

implicit none
integer :: year, month
integer :: s_year, s_month, s_day, s_hour, s_min, duration
integer :: days
integer, parameter :: min_of_day = 60*24

  s_year = year; s_month = month
  s_day = 1
  s_hour = 0; s_min = 0

 call days_of_month( year, month, days )
 duration = days * min_of_day

end
 



subroutine days_of_month(year, month, days)
! number of days in year/month
implicit none
integer :: year, month, days
  logical, external :: leepyear

 integer :: m(12)
  m(1) = 31; m(2) = 28; m(3) = 31; m(4) = 30
  m(5) = 31; m(6) = 30; m(7) = 31; m(8) = 31
  m(9) = 30; m(10) = 31; m(11) = 30; m(12) = 31

 if(leepyear(year)) then
  m(2) = 29
 end if

 days = m(month)


end


logical function leepyear( year )
implicit none
 integer :: year

 if( mod(year, 4) > 0 ) then
   leepyear  = .FALSE.
 else if( mod(year, 100) > 0 ) then
   leepyear = .TRUE.
 else if( mod(year, 400) > 0 ) then
   leepyear = .FALSE.
 else
   leepyear = .TRUE.
 end if

return
end

