[Fortran] 纯文本查看 复制代码
Program www_fcode_cn
Implicit none
write(*,*) timeall( 1994 , 1 , 365 , 24 )
write(*,*) timeall( 1994 , 2 , 365 , 0 )
contains
real function timeall( yr , dayofyear , Days_Of_Year , hr )
integer :: yr , dayofyear , Days_Of_Year , hr
timeall = REAL(yr)+(REAL(dayofyear)-0.99)/Days_Of_Year+REAL(hr)/(Days_Of_Year*24)
end function timeall
End Program www_fcode_cn
[Fortran] 纯文本查看 复制代码
subroutine convertday (yr,mon,day,hr,timeall,dayofyear)
INTEGER :: yr,mon,day,hr,dayofyear
REAL*8 :: timeall
Integer :: DAY_OF_MONTH(12) , Days_Of_Year
DAY_OF_MONTH = (/31,28,31,30,31,30,31,31,30,31,30,31/)
if (MOD(yr,4)==0 .and. MOD(yr,100)/=0) then
DAY_OF_MONTH(2) = 29
Days_Of_Year = 366
else if(MOD(yr,4)==0 .and. MOD(yr,100)==0 .and. MOD(yr,400)==0) then
DAY_OF_MONTH(2) = 29
Days_Of_Year = 366
else !(MOD(yr,4)==0 .and. MOD(yr,100)==0 .and. MOD(yr,400)/=0) then
Days_Of_Year = 365
end if
if ( mon > 1 ) then
dayofyear = day + sum( DAY_OF_MONTH(1:mon-1) )
else
dayofyear = day
end if
timeall = REAL(yr)+(REAL(dayofyear)-0.99)/Days_Of_Year+REAL(hr)/(Days_Of_Year*24)
end subroutine