append_unique_primary_layer_id Subroutine

subroutine append_unique_primary_layer_id(node_name, ids)

Append a layer id parsed from a primary node name node_.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: node_name

Node name potentially containing a primary layer id

integer, intent(inout), allocatable :: ids(:)

Unique set of discovered layer ids


Source Code

  subroutine append_unique_primary_layer_id(node_name, ids)
    !! Append a layer id parsed from a primary node name node_<id>.
    implicit none

    ! Arguments
    character(*), intent(in) :: node_name
    !! Node name potentially containing a primary layer id
    integer, allocatable, intent(inout) :: ids(:)
    !! Unique set of discovered layer ids

    ! Local variables
    integer :: layer_id, i
    !! Parsed id and loop index
    logical :: is_primary, exists
    !! Primary-node flag and duplicate-id flag

    call parse_primary_layer_id(node_name, layer_id, is_primary)
    if(.not.is_primary) return

    exists = .false.
    do i = 1, size(ids)
       if(ids(i) .eq. layer_id)then
          exists = .true.
          exit
       end if
    end do
    if(.not.exists) ids = [ids, layer_id]

  end subroutine append_unique_primary_layer_id