layer_from_id Module Function

module function layer_from_id(this, id) result(layer)

Get layer from its ID

Arguments

Type IntentOptional Attributes Name
class(network_type), intent(in), target :: this

Instance of network

integer, intent(in) :: id

Layer ID

Return Value class(base_layer_type), pointer

Layer


Source Code

  module function layer_from_id(this, id) result(layer)
    !! Get layer from its ID
    implicit none

    ! Arguments
    class(network_type), intent(in), target :: this
    !! Instance of network
    integer, intent(in) :: id
    !! Layer ID

    class(base_layer_type), pointer :: layer
    !! Layer

    ! Local variables
    integer :: i, itmp1
    !! Loop index

    itmp1 = 0
    do i = 1, size(this%model, dim = 1)
       if(this%model(i)%layer%id.eq.id)then
          if(itmp1.ne.0)then
             call stop_program("multiple layers with same ID found")
             return
          end if
          layer => this%model(i)%layer
          itmp1 = itmp1 + 1
       end if
    end do

  end function layer_from_id