ESMF_AlarmEQ Function

private impure elemental function ESMF_AlarmEQ(alarm1, alarm2)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Alarm), intent(in) :: alarm1
type(ESMF_Alarm), intent(in) :: alarm2

Return Value logical


Source Code

      impure elemental function ESMF_AlarmEQ(alarm1, alarm2)
!
! !RETURN VALUE:
      logical :: ESMF_AlarmEQ

! !ARGUMENTS:
      type(ESMF_Alarm), intent(in) :: alarm1
      type(ESMF_Alarm), intent(in) :: alarm2

! !DESCRIPTION:
!     This method overloads the (==) operator for the {\tt ESMF\_Alarm}
!     class.  See "interface operator(==)" above for complete description.
!
!EOPI
      ESMF_INIT_TYPE alarminit1, alarminit2
      integer :: localrc1, localrc2                 ! local return codes
      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
      alarminit1 = ESMF_AlarmGetInit(alarm1)
      alarminit2 = ESMF_AlarmGetInit(alarm2)

      if (alarminit1.eq.ESMF_INIT_CREATED.and. &
          alarminit2.eq.ESMF_INIT_CREATED) then
        ! invoke C to C++ entry point
        call c_ESMC_AlarmEQ(alarm1, alarm2, ESMF_AlarmEQ)
      else
        ! log error, convert to return code, and compare
        lval1 = ESMF_IMErr(alarminit1, ESMF_CONTEXT, rc=localrc1)
        lval2 = ESMF_IMErr(alarminit2, ESMF_CONTEXT, rc=localrc2)
        ESMF_AlarmEQ = localrc1.eq.localrc2
      endif

      end function ESMF_AlarmEQ