Modified SUBROUTINE cerca connessioni for joined grids