getMaxLenCnt
– get length of a list and max number of data in the nodes
Get length of a list and max number of data in the nodes so that maxLen/count can been used to allocate array.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(out) | :: | maxLen | |||
integer, | intent(out) | :: | count | |||
type(iNode), | optional, | pointer | :: | iList | ||
type(rNode), | optional, | pointer | :: | rList | ||
type(cNode), | optional, | pointer | :: | cList |
subroutine getMaxLenCnt(maxLen, count, iList, rList, cList) ! ! !INPUT PARAMETERS: ! type(iNode), pointer, OPTIONAL :: iList type(cNode), pointer, OPTIONAL :: cList type(rNode), pointer, OPTIONAL :: rList ! ! !OUTPUT PARAMETERS: ! integer, intent(out) :: maxLen integer, intent(out) :: count ! !------------------------------------------------------------------------------ type(iNode), pointer :: p ! int pointer for int list type(rNode), pointer :: rp ! real pointer for real list type(cNode), pointer :: cp ! char pointer for char list count = 0 maxLen = 0 ! get maxLen/count from a integer list if ( present(iList) ) then allocate(p) p = iList do while ( associated(p) ) if (p%count .gt. maxLen) maxLen = p%count count = count + 1 p => p%next end do end if ! get maxLen/count from a real list if ( present(rList) ) then allocate(rp) rp = rList do while ( associated(rp) ) if (rp%count .gt. maxLen) maxLen = rp%count count = count + 1 rp => rp%next end do end if ! get maxLen/count from a character list if ( present(cList) ) then allocate(cp) cp = cList do while ( associated(cp) ) if (cp%count .gt. maxLen) maxLen = cp%count count = count + 1 cp => cp%next end do end if end subroutine getMaxLenCnt