Line data Source code
1 : module bnddyi_mod 2 : 3 : implicit none 4 : 5 : private 6 : 7 : public :: bnddyi 8 : 9 : contains 10 : 11 0 : subroutine bnddyi (ncdate, ncsec, doy) 12 : !----------------------------------------------------------------------- 13 : ! 14 : ! Purpose: Convert date and seconds of day to floating point calendar day, for 15 : ! boundary dataset handling 16 : ! 17 : ! Method: Use table of days per month to do conversion 18 : ! 19 : ! Author: CCM Core Group 20 : ! 21 : !----------------------------------------------------------------------- 22 : use shr_kind_mod, only: r8 => shr_kind_r8 23 : use cam_abortutils, only: endrun 24 : use cam_logfile, only: iulog 25 : !--------------------------Arguments------------------------------------ 26 : ! 27 : ! Arguments 28 : ! 29 : integer, intent(in) :: ncdate ! Current date as yymmdd or yyyymmdd 30 : integer, intent(in) :: ncsec ! Seconds of day for current date 31 : 32 : real(r8), intent(out) :: doy ! Day of year 33 : ! 34 : ! Local Variables 35 : ! 36 : integer mnth ! Month number 37 : integer mday ! Day number of month 38 : integer jdcon(12) ! Starting day number for each month 39 : save jdcon 40 : data jdcon/0,31,59,90,120,151,181,212,243,273,304,334/ 41 : ! 42 : ! Decode month and day 43 : ! 44 0 : mnth = mod(ncdate,10000)/100 45 0 : if (mnth < 1 .or. mnth > 12) then 46 0 : write(iulog,*)'BNDDYI: Bad month index=', mnth 47 0 : call endrun 48 : end if 49 0 : mday = mod(ncdate,100) 50 0 : doy = jdcon(mnth) + mday + ncsec/86400._r8 51 : 52 0 : if (doy < 1._r8 .or. doy > 366._r8) then 53 0 : write(iulog,*)'BNDDYI: bad day of year = ',doy 54 0 : call endrun 55 : end if 56 : ! 57 0 : return 58 : end subroutine bnddyi 59 : 60 : end module bnddyi_mod