[Fortran] 纯文本查看 复制代码
subroutine day1year()
implicit none
integer :: year , mon , days
common year , mon
Integer :: DaysInMonth(12) = [31,28,31,30,31,30,31,31,30,31,30,31]
if ( ( (MOD(year,4)==0).and.(MOD(year,100)/=0) ) .or. (mod(year,400)==0) ) then
DaysInMonth(2) = 29
else
DaysInMonth(2) = 28
end if
days = sum( DaysInMonth )
end subroutine day1year
subroutine dayfromyear( year , mon , day )
implicit none
integer :: day , i , daylast
Integer :: DaysInMonth(12) = [31,28,31,30,31,30,31,31,30,31,30,31]
integer :: k
integer :: years(51) = (/(k,k=1957,2007)/)
integer :: sumday = 0
do i=1,k,1
call day1year (years(i))
sumday = sumday + days
end do
daylast = sum( DaysInMonth(:mon-1) ) + day +sumday
end subroutine