subroutine circulator_init_part2(me,krn,cfg)
type(circulator_t), intent(inout) :: me
type(krn_t), target, intent(inout) :: krn
class(input_t), pointer, intent(in) :: cfg
type(input_t), allocatable :: branches(:)
branches = cfg%dict1d('link')
me%br(1)%p => krn%FF_flux_ports(krn%FF_flux_list%find(branches(1)%str('id'),&
convert2int_port(branches(1)%str('node'))))
if(me%br(1)%p%connected) then
print*,'Port ',branches(1)%int('node'),' belonging to ',branches(1)%str('id'),' already connected to a link'
stop
endif
if(convert2int_port(branches(1)%str('node'))/=2) then
print*,'The node of the 1st link must be out'
stop
endif
me%br(1)%p%connected=.true.
me%br(2)%p => krn%FF_flux_ports(krn%FF_flux_list%find(branches(2)%str('id'),&
convert2int_port(branches(2)%str('node'))))
if(me%br(2)%p%connected) then
print*,'Port ',branches(2)%int('node'),' belonging to ',branches(2)%str('id'),' already connected to a link'
stop
endif
me%br(2)%p%connected=.true.
call krn%coo_add_link(me%br(1)%p, me%br(2)%p, idx_4x4_col, idx_4x4_row, to_ptr_arr(me%MxInOut))
call krn%coo_add_link(me%br(2)%p, me%br(1)%p, idx_4x4_col, idx_4x4_row, to_ptr_arr(me%MxOutin))
end subroutine circulator_init_part2