      logical function leapyear (nyear)

c This function decides whether a particular year is a leap year
c Rule 1: Years not exactly divisible by four are not leap years
c Rule 2: Years not exactly divisible by one hundred are leap years
c Rule 3: Years not exactly divisible by four hundred are not leapyears
c         Years exactly divisible by four hundred are leapyears

      logical test
      test(n) = (nyear/n)*n .eq. nyear

      leapyear = test(4)
      if (leapyear) then
        leapyear = .not.test(100)
        if (.not.leapyear) leapyear = test(400)
      end if
      return
      end
