Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(MAPL_MetaComp), | intent(inout) | :: | MAPLOBJ | |||
type(ESMF_Alarm), | intent(inout) | :: | ALARM(:) | |||
integer, | intent(in) | :: | filetype(:) | |||
integer, | intent(out), | optional | :: | rc |
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