compute_incymd Function

function compute_incymd(nymd, m) result(incymd)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nymd
integer, intent(in) :: m

Return Value integer


Calls

proc~~compute_incymd~~CallsGraph proc~compute_incymd compute_incymd proc~is_leap_year is_leap_year proc~compute_incymd->proc~is_leap_year

Called by

proc~~compute_incymd~~CalledByGraph proc~compute_incymd compute_incymd proc~tick tick proc~tick->proc~compute_incymd program~time_ave time_ave program~time_ave->proc~tick

Source Code

   function compute_incymd (nymd,m) result(incymd)
      integer :: incymd
      integer, intent(in) :: nymd
      integer, intent(in) :: m
!***********************************************************************
!  purpose
!     incymd:  nymd changed by one day
!     modymd:  nymd converted to julian date
!  description of parameters
!     nymd     current date in yymmdd format
!     m        +/- 1 (day adjustment)
!
!***********************************************************************
!*                  goddard laboratory for atmospheres                 *
!***********************************************************************

      integer ndpm(12)
      data    ndpm /31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31/
      integer :: ny,nm,nd
!***********************************************************************
!
      ny = nymd / 10000
      nm = mod(nymd,10000) / 100
      nd = mod(nymd,100) + m

      if (nd.eq.0) then
         nm = nm - 1
         if (nm.eq.0) then
            nm = 12
            ny = ny - 1
         endif
         nd = ndpm(nm)
         if (nm.eq.2 .and. is_leap_year(ny))  nd = 29
      endif

      if (nd.eq.29 .and. nm.eq.2 .and. is_leap_year(ny))  go to 20

      if (nd.gt.ndpm(nm)) then
         nd = 1
         nm = nm + 1
         if (nm.gt.12) then
            nm = 1
            ny = ny + 1
         endif
      endif

20    continue
      incymd = ny*10000 + nm*100 + nd
      return

   end function compute_incymd