ESMF_CalendarSetCustom Subroutine

private subroutine ESMF_CalendarSetCustom(calendar, keywordEnforcer, daysPerMonth, secondsPerDay, daysPerYear, daysPerYearDn, daysPerYearDd, name, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Calendar), intent(inout) :: calendar
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
integer, intent(in), optional :: daysPerMonth(:)
integer(kind=ESMF_KIND_I4), intent(in), optional :: secondsPerDay
integer(kind=ESMF_KIND_I4), intent(in), optional :: daysPerYear
integer(kind=ESMF_KIND_I4), intent(in), optional :: daysPerYearDn
integer(kind=ESMF_KIND_I4), intent(in), optional :: daysPerYearDd
character(len=*), intent(in), optional :: name
integer, intent(out), optional :: rc

Source Code

      subroutine ESMF_CalendarSetCustom(calendar, keywordEnforcer, &
        daysPerMonth, secondsPerDay, &
        daysPerYear, daysPerYearDn, daysPerYearDd, name, rc)

! !ARGUMENTS:
      type(ESMF_Calendar),  intent(inout)         :: calendar
      type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
      integer,              intent(in),  optional :: daysPerMonth(:)
      integer(ESMF_KIND_I4),intent(in),  optional :: secondsPerDay
      integer(ESMF_KIND_I4),intent(in),  optional :: daysPerYear
      integer(ESMF_KIND_I4),intent(in),  optional :: daysPerYearDn
      integer(ESMF_KIND_I4),intent(in),  optional :: daysPerYearDd
      character (len=*),    intent(in),  optional :: name
      integer,              intent(out), optional :: rc

!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \end{itemize}
!
! !DESCRIPTION:
!     Sets properties in a custom {\tt ESMF\_Calendar}.
!
!     The arguments are:
!     \begin{description}
!     \item[calendar]
!          The object instance to initialize.
!     \item[{[daysPerMonth]}]
!          Integer array of days per month, for each month of the year.
!          The number of months per year is variable and taken from the
!          size of the array.  If unspecified, months per year = 0,
!          with the days array undefined.
!     \item[{[secondsPerDay]}]
!          Integer number of seconds per day.  Defaults to 0 if not 
!          specified.
!     \item[{[daysPerYear]}]
!          Integer number of days per year.  Use with daysPerYearDn and
!          daysPerYearDd (see below) to specify a days-per-year calendar
!          for any planetary body.  Default = 0.
!     \item[{[daysPerYearDn]}]
!          Integer numerator portion of fractional number of days per year
!          (daysPerYearDn/daysPerYearDd).
!          Use with daysPerYear (see above) and daysPerYearDd (see below) to
!          specify a days-per-year calendar for any planetary body.
!          Default = 0.
!     \item[{[daysPerYearDd]}]
!          \begin{sloppypar}
!          Integer denominator portion of fractional number of days per year
!          (daysPerYearDn/daysPerYearDd).
!          Use with daysPerYear and daysPerYearDn (see above) to
!          specify a days-per-year calendar for any planetary body.
!          Default = 1.
!          \end{sloppypar}
!     \item[{[name]}]
!          The new name for this calendar.
!     \item[{[rc]}]
!          Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!     
!EOP

      ! initialize name length to zero for non-existent name
      !   and initialize number of months per year to zero for not-present
      !   daysPerMonth
      integer :: nameLen
      integer :: monthsPerYear
      integer :: localrc                        ! local return code

      ! Assume failure until success
      if (present(rc)) rc = ESMF_RC_NOT_IMPL
      localrc = ESMF_RC_NOT_IMPL

      ! check input
      ESMF_INIT_CHECK_DEEP(ESMF_CalendarGetInit,calendar,rc)

      nameLen = 0
      monthsPerYear = 0

      ! get length of given name for C++ validation
      if (present(name)) then
        nameLen = len_trim(name)
      end if

      ! get size of given daysPerMonth array for C++ validation
      if (present(daysPerMonth)) then
        monthsPerYear = size(daysPerMonth)
      end if

      ! invoke C to C++ entry point

      if (present(daysPerMonth)) then
        call c_ESMC_CalendarSetCustom1(calendar, &
                                      nameLen, name, &
                                      daysPerMonth(1), monthsPerYear, &
                                      secondsPerDay, &
                                      daysPerYear, daysPerYearDn, &
                                      daysPerYearDd, localrc)
        if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
          ESMF_CONTEXT, rcToReturn=rc)) return
      else
        call c_ESMC_CalendarSetCustom0(calendar, &
                                      nameLen, name, &
                                      monthsPerYear, &
                                      secondsPerDay, &
                                      daysPerYear, daysPerYearDn, &
                                      daysPerYearDd, localrc)
        if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
          ESMF_CONTEXT, rcToReturn=rc)) return
      end if

      ! Return success
      if (present(rc)) rc = ESMF_SUCCESS
      end subroutine ESMF_CalendarSetCustom