Unexpected seg. fault allocating a not-allocated array

I am checking the allocation but none of them is allocated, I did check by printing the values but I didn’t add it to the snipped of code I posted.
I added those lines as a safe measurement to make sure that the problem was not having a pre-allocated variable.

I tried to provide an explicit interface to the subroutine calling “build_H_sector_fulldiag” as follows:

subroutine diagonalize_aim(aim_problem,state_list,verb_,ifrag_)
    interface
       subroutine build_H_sector_fulldiag(aim_problem,SectorI,Hmat,ifrag_)
         USE GRISBOLT_COMMON, only: AIM
         USE GRISBOLT_FOCKSPACE, only: sector
         type(AIM),allocatable,intent(in)   :: aim_problem
         type(sector)                       :: SectorI
         complex(8),dimension(:,:)          :: Hmat
         integer,optional :: ifrag_
       end subroutine build_H_sector_fulldiag
    end interface
    !> routine to find the GroundState(s) of the AIM
    type(AIM),allocatable,intent(inout)             :: aim_problem
    type(sparse_espace), intent(inout)              :: state_list
    !
[rest of the code]
end subroutine

and now it fails to compile with the following error:

bethe_x.f90                            done.
bethe_x                                failed.
[100%] Compiling...
/usr/bin/ld: build/gfortran_D60D5F445CDA73CD/BETHE_2ORB_GRISOLT/libBETHE_2ORB_GRISOLT.a(.._.._GRISBOLT_src_GRISBOLT_AIM_GRISBOLT_AIM.f90.o): in function `__grisbolt_aim_MOD_diagonalize_aim':
/home/samuele/GRISB/TESTS_GRISBOLT/BETHE_2ORB_GRISBOLT/../../GRISBOLT/src/GRISBOLT_AIM/GRISBOLT_AIM.f90:128: undefined reference to `build_h_sector_fulldiag_'
/usr/bin/ld: /home/samuele/GRISB/TESTS_GRISBOLT/BETHE_2ORB_GRISBOLT/../../GRISBOLT/src/GRISBOLT_AIM/GRISBOLT_AIM.f90:147: undefined reference to `build_h_sector_fulldiag_'
collect2: error: ld returned 1 exit status
<ERROR> Compilation failed for object " bethe_x "
<ERROR> stopping due to failed compilation
STOP 1

So it does not recognize it, maybe I am doing something wrong passing it.
Anyway before passing the interface the code was entering the subroutine.