subroutine MAPL_SetVarSpecForCC(gcA, gcB, ccAxB, rc)
type(ESMF_GridComp), intent(inout) :: GCA
type(ESMF_GridComp), intent(inout) :: GCB
type(ESMF_CplComp) , intent(inout) :: CCAxB
integer, optional, intent( out) :: RC ! Error code:
! Local vars
character(len=ESMF_MAXSTR) :: NAME
integer :: status
integer :: I, N, STAT
type (MAPL_VarSpec), pointer :: SRCS(:)
type (MAPL_VarSpec), pointer :: DSTS(:)
type (MAPL_VarSpec), pointer :: IM_SPECS(:), EX_SPECS(:)
! Begin
NULLIFY(SRCS)
NULLIFY(DSTS)
call MAPL_GridCompGetVarSpecs(gcA, EXPORT=EX_SPECS, RC=status)
_VERIFY(status)
call MAPL_GridCompGetVarSpecs(gcB, IMPORT=IM_SPECS, RC=status)
_VERIFY(status)
DO I = 1, size(IM_SPECS)
call MAPL_VarSpecGet(IM_SPECS(I), STAT=STAT, RC=status)
_VERIFY(status)
IF (IAND(STAT, MAPL_BundleItem) /= 0) then
cycle
END IF
call MAPL_VarSpecAddRefToList(DSTS, IM_SPECS(I), RC=status)
_VERIFY(status)
END DO
IF (.not. associated(DSTS)) then
_RETURN(ESMF_FAILURE)
END IF
DO I = 1, size(DSTS)
call MAPL_VarSpecGet(DSTS(I), STAT=STAT, SHORT_NAME=NAME, RC=status)
_VERIFY(status)
N = MAPL_VarSpecGetIndex(EX_SPECS, NAME, RC=status)
if(N /= -1) then
_VERIFY(status)
else
call WRITE_PARALLEL("ERROR: cannot match spec:")
call MAPL_VarSpecPrint(DSTS(I))
_RETURN(ESMF_FAILURE)
endif
call MAPL_VarSpecAddRefToList(SRCS, DSTS(I), RC=status)
_VERIFY(status)
END DO
call MAPL_CplCompSetVarSpecs(ccAxB, SRCS, DSTS, RC=status)
_VERIFY(status)
_RETURN(ESMF_SUCCESS)
end subroutine MAPL_SetVarSpecForCC