ESMF_CalendarEQ Function

private impure elemental function ESMF_CalendarEQ(calendar1, calendar2)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Calendar), intent(in) :: calendar1
type(ESMF_Calendar), intent(in) :: calendar2

Return Value logical


Source Code

      impure elemental function ESMF_CalendarEQ(calendar1, calendar2)
! 
! !RETURN VALUE:
      logical :: ESMF_CalendarEQ

! !ARGUMENTS:
      type(ESMF_Calendar), intent(in) :: calendar1
      type(ESMF_Calendar), intent(in) :: calendar2

! !DESCRIPTION:
!     This method overloads the (==) operator for the {\tt ESMF\_Calendar}
!     class.  See "interface operator(==)" above for complete description.
!
!EOPI

      ESMF_INIT_TYPE calinit1, calinit2
      integer :: localrc1, localrc2
      logical :: lval1, lval2

      ! Use the following logic, rather than "ESMF-INIT-CHECK-DEEP", to gain 
      ! init checks on both args, and in the case where both are uninitialized,
      ! to distinguish equality based on uninitialized type (uncreated,
      ! deleted).

      ! TODO: Consider moving this logic to C++: use Base class? status?
      !       Or replicate logic for C interface also.

      ! check inputs
      calinit1 = ESMF_CalendarGetInit(calendar1)
      calinit2 = ESMF_CalendarGetInit(calendar2)

      ! TODO: this line must remain split in two for SunOS f90 8.3 127000-03
      if (calinit1 .eq. ESMF_INIT_CREATED .and. &
          calinit2 .eq. ESMF_INIT_CREATED) then
        ! invoke C to C++ entry point
        call c_ESMC_CalendarEQ(calendar1, calendar2, ESMF_CalendarEQ)
      else
        ! log error, convert to return code, and compare
        lval1 = ESMF_IMErr(calinit1, ESMF_CONTEXT, rc=localrc1)
        lval2 = ESMF_IMErr(calinit2, ESMF_CONTEXT, rc=localrc2)
        ESMF_CalendarEQ = localrc1.eq.localrc2
      endif

      end function ESMF_CalendarEQ