MAPL_AddRecord Subroutine

public subroutine MAPL_AddRecord(MAPLOBJ, ALARM, filetype, rc)

Arguments

Type IntentOptional Attributes Name
type(MAPL_MetaComp), intent(inout) :: MAPLOBJ
type(ESMF_Alarm), intent(inout) :: ALARM(:)
integer, intent(in) :: filetype(:)
integer, intent(out), optional :: rc

Calls

proc~~mapl_addrecord~~CallsGraph proc~mapl_addrecord MAPL_AddRecord ESMF_AlarmGet ESMF_AlarmGet proc~mapl_addrecord->ESMF_AlarmGet interface~mapl_assert MAPL_Assert proc~mapl_addrecord->interface~mapl_assert proc~mapl_return MAPL_Return proc~mapl_addrecord->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mapl_addrecord->proc~mapl_verify at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception

Called by

proc~~mapl_addrecord~~CalledByGraph proc~mapl_addrecord MAPL_AddRecord proc~mapl_genericinitialize MAPL_GenericInitialize proc~mapl_genericinitialize->proc~mapl_addrecord

Source Code

   subroutine MAPL_AddRecord(MAPLOBJ, ALARM, FILETYPE, RC)
      type(MAPL_MetaComp), intent(inout) :: MAPLOBJ
      type(ESMF_Alarm),    intent(INout) :: ALARM(:)
      integer,             intent(in ) :: filetype(:)
      integer, optional,   intent(out) :: rc

      integer :: NRA
      integer :: NR
      integer :: NRT
      integer :: I
      integer :: J
      integer :: K
      logical :: found
      type(ESMF_Alarm), allocatable :: R_ALARM(:)
      integer         , allocatable :: R_FILETYPE(:)
      character(len=ESMF_MAXSTR) :: ANAME
      character(len=ESMF_MAXSTR) :: NAME

      integer :: status
      character(len=ESMF_MAXSTR), parameter :: Iam="MAPL_AddRecord"

      NRA = size(ALARM)
      _ASSERT(size(filetype) == NRA,'needs informative message')

      if (.not. associated(MAPLOBJ%RECORD)) then
         allocate(MAPLOBJ%RECORD, stat=status)
         _VERIFY(status)
         MAPLOBJ%RECORD%IMP_LEN = 0
         MAPLOBJ%RECORD%INT_LEN = 0
         allocate(MAPLOBJ%RECORD%alarm(NRA),stat=status)
         _VERIFY(status)
         allocate(MAPLOBJ%RECORD%filetype(NRA),stat=status)
         _VERIFY(status)
         MAPLOBJ%RECORD%alarm = alarm
         MAPLOBJ%RECORD%filetype = filetype
      else
         NR = size(MAPLOBJ%RECORD%alarm)
         NRT = NR + NRA ! maximum size
         allocate(r_alarm(NRT), r_filetype(NRT), stat=status)
         _VERIFY(status)
         K = NR
         r_alarm(1:K) = MAPLOBJ%RECORD%alarm
         r_filetype(1:K) = MAPLOBJ%RECORD%filetype
         found = .false.
         do I = 1, NRA
            call ESMF_AlarmGet(ALARM(I), name=ANAME, RC=status)
            _VERIFY(status)
            do J = 1, NR
               call ESMF_AlarmGet(MAPLOBJ%RECORD%ALARM(J), name=NAME, RC=status)
               _VERIFY(status)
               if(ANAME == NAME .and. &
                    filetype(I) == MAPLOBJ%RECORD%FILETYPE(J)) then
                  found = .true.
                  exit
               end if
            end do
            if (.not. found) then
               K = K+1
               r_alarm(K) = ALARM(I)
               r_filetype(K) = FILETYPE(I)
            end if
         end do
         if (K /= NR) then
            deallocate(MAPLOBJ%RECORD%filetype)
            deallocate(MAPLOBJ%RECORD%alarm)
            allocate(MAPLOBJ%RECORD%alarm(K),stat=status)
            _VERIFY(status)
            allocate(MAPLOBJ%RECORD%filetype(K),stat=status)
            _VERIFY(status)
            MAPLOBJ%RECORD%alarm = r_alarm(1:K)
            MAPLOBJ%RECORD%filetype = r_filetype(1:K)
         end if
         deallocate(r_filetype, r_alarm)
      end if
      _RETURN(ESMF_SUCCESS)
   end subroutine MAPL_AddRecord