FY4B_C_SPMS/ProduceBackground/calculate_time_to_msecond.f90

38 lines
1.6 KiB
Fortran

Subroutine CALCULATE_TIME2MSECOND( &
time , & ! in
second ) ! out
real(kind=8) :: nyear
real(kind=8) :: nmonth
real(kind=8) :: nday
real(kind=8) :: nhour
real(kind=8) :: nminute
real(kind=8) :: time
real(kind=8) :: second
integer(kind=8) :: leapyear
integer(kind=8), dimension(12) :: days = (/31, 28, 31, 30 ,31, 30, 31, 31, 30, 31, 30, 31/)
nyear = aint(time/1e8)
nmonth = aint((time-nyear*1e8)/1e6)
nday = int((time-nyear*1e8-nmonth*1e6)/1e4)
nhour = int((time-nyear*1e8-nmonth*1e6-nday*1e4)/100)
nminute= time-nyear*1e8-nmonth*1e6-nday*1e4-nhour*100
!print*,nyear,nmonth,nday,nhour,nminute
if(mod(int(nyear),4)==0 .and. int(nmonth)>2.0)then
leapyear = 1
else
leapyear = 0
endif
! print*,'leapyear=',leapyear
if (nmonth>1)then
second = (aint((nyear-1973)*365.25)+3*365+1+sum(days(1:nmonth-1))+leapyear+nday-1)*(24.*60.*60.)+nhour*60.*60.+nminute*60.
! print*,'-----',aint((nyear-1973)*365.25)+3*365+1+sum(days(1:nmonth-1))+leapyear+nday-1
else
second = (aint((nyear-1973)*365.25)+3*365+1+nday-1)*(24.*60.*60.)+nhour*60.*60.+nminute*60.
endif
Return
End Subroutine CALCULATE_TIME2MSECOND