Skip to content

Commit

Permalink
Intermediate commit:
Browse files Browse the repository at this point in the history
fixed (probably) a compilation bug with intel compiler ifort/ifx > 2019
(tested on 2021). For some reason, if variables are bound to c via
iso_c_binding, the intel compiler creates duplicate symbols.
E.g. Nspin, Norb in ED_INPUT_VARS.
If another module imports ED_INPUT_VARS and a function there
defined tries to use input parameters with defined shapes containing
Nspin or Norb, the function is compiled, but any call to it results in a
compilation error:

`error #7556: The external name for this symbol conflicts
with a previously declared external name.   [ED_INPUT_VARS^NORB]`

The fix provided here uses a "use ED_INPUT_VARS, only: Nspin,Norb"
inside the offending functions. This seems to remove the issue. To avoid
errors in unaffected compilation environments, the statement is embedded
in a precompiler flag for the intel compilers.
  • Loading branch information
lcrippa committed Nov 23, 2024
1 parent d7117d5 commit 4c14463
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 11 deletions.
6 changes: 6 additions & 0 deletions src/ED_AUX_FUNX.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,9 @@ end subroutine search_chemical_potential
!PURPOSE : Print Hloc
!+------------------------------------------------------------------+
subroutine print_Hloc_nn_c(hloc,file)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb
#endif
complex(8),dimension(Nnambu*Nspin,Nnambu*Nspin,Norb,Norb) :: hloc
character(len=*),optional :: file
integer :: iorb,jorb,ispin,jspin,Nso,unit
Expand Down Expand Up @@ -1568,6 +1571,9 @@ subroutine print_Hloc_nn_c(hloc,file)
end subroutine print_Hloc_nn_c

subroutine print_Hloc_so_c(hloc,file)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb
#endif
complex(8),dimension(Nnambu*Nspin*Norb,Nnambu*Nspin*Norb) :: hloc
character(len=*),optional :: file
integer :: is,js,Nso,unit
Expand Down
45 changes: 45 additions & 0 deletions src/ED_BATH/ED_BATH_AUX.f90
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ MODULE ED_BATH_AUX


subroutine Hreplica_site(site)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
integer :: site
if(site<1.OR.site>size(Hreplica_lambda_ineq,1))stop "ERROR Hreplica_site: site not in [1,Nlat]"
if(.not.allocated(Hreplica_lambda_ineq))stop "ERROR Hreplica_site: Hreplica_lambda_ineq not allocated"
Expand All @@ -77,6 +80,9 @@ end subroutine Hreplica_site


function Hreplica_build(lambdavec) result(H)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
!
!This function is used to reconstruct the local bath Hamiltonian from basis expansion given the vector of :math:`\vec{\lambda}` parameters :math:`h^p=\sum_i \lambda^p_i O_i`. The resulting Hamiltonian has dimensions [ |Nspin| , |Nspin| , |Norb| , |Norb| ]
!
Expand All @@ -98,6 +104,9 @@ function Hreplica_build(lambdavec) result(H)
end function Hreplica_build

function Hreplica_mask(wdiag,uplo) result(Hmask)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
logical,optional :: wdiag,uplo
logical :: wdiag_,uplo_
complex(8),dimension(Nnambu*Nspin,Nnambu*Nspin,Norb,Norb) :: H
Expand Down Expand Up @@ -141,13 +150,19 @@ end function Hreplica_mask


subroutine Hgeneral_site(site)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
integer :: site
if(site<1.OR.site>size(Hgeneral_lambda_ineq,1))stop "ERROR Hgeneral_site: site not in [1,Nlat]"
if(.not.allocated(Hgeneral_lambda_ineq))stop "ERROR Hgeneral_site: Hgeneral_lambda_ineq not allocated"
Hgeneral_lambda(:,:) = Hgeneral_lambda_ineq(site,:,:)
end subroutine Hgeneral_site

function Hgeneral_build(lambdavec) result(H)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
!
!This function is used to reconstruct the local bath Hamiltonian from basis expansion given the vector of :math:`\vec{\lambda}` parameters :math:`h^p=\sum_i \lambda^p_i O_i`. The resulting Hamiltonian has dimensions [ |Nspin| , |Nspin| , |Norb| , |Norb| ]
!
Expand All @@ -169,6 +184,9 @@ function Hgeneral_build(lambdavec) result(H)
end function Hgeneral_build

function Hgeneral_mask(wdiag,uplo) result(Hmask)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
logical,optional :: wdiag,uplo
logical :: wdiag_,uplo_
complex(8),dimension(Nnambu*Nspin,Nnambu*Nspin,Norb,Norb) :: H
Expand Down Expand Up @@ -218,6 +236,9 @@ end function Hgeneral_mask


function get_Whyb_matrix_1orb(v,u) result(w)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
real(8),dimension(Nspin,Nbath) :: v,u
real(8),dimension(Nspin,Nspin,Nbath) :: w
integer :: ispin
Expand All @@ -229,6 +250,9 @@ function get_Whyb_matrix_1orb(v,u) result(w)
end function get_Whyb_matrix_1orb

function get_Whyb_matrix_Aorb(v,u) result(w)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
real(8),dimension(Nspin,Norb,Nbath) :: v,u
real(8),dimension(Nspin,Nspin,Norb,Nbath) :: w
integer :: ispin
Expand All @@ -240,6 +264,9 @@ function get_Whyb_matrix_Aorb(v,u) result(w)
end function get_Whyb_matrix_Aorb

function get_Whyb_matrix_dmft_bath(dmft_bath_) result(w)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
type(effective_bath) :: dmft_bath_
real(8),dimension(Nspin,Nspin,Norb,Nbath) :: w
integer :: ispin
Expand All @@ -258,6 +285,9 @@ end function get_Whyb_matrix_dmft_bath
!PURPOSE : Check if a matrix is the identity
!+-------------------------------------------------------------------+
function is_identity_nn(mnnn) result(flag)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
complex(8),dimension(Nnambu*Nspin,Nnambu*Nspin,Norb,Norb) :: mnnn
real(8),dimension(Nnambu*Nspin*Norb,Nnambu*Nspin*Norb) :: mtmp
integer :: i,j
Expand All @@ -280,6 +310,9 @@ function is_identity_nn(mnnn) result(flag)
end function is_identity_nn

function is_identity_so(mlso) result(flag)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
complex(8),dimension(Nnambu*Nspin*Norb,Nnambu*Nspin*Norb) :: mlso
real(8),dimension(Nnambu*Nspin*Norb,Nnambu*Nspin*Norb) :: mtmp
integer :: i,j
Expand Down Expand Up @@ -307,6 +340,9 @@ end function is_identity_so
!PURPOSE : Check if a matrix is diagonal
!+-------------------------------------------------------------------+
function is_diagonal_nn(mnnn) result(flag)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
complex(8),dimension(Nnambu*Nspin,Nnambu*Nspin,Norb,Norb) :: mnnn
complex(8),dimension(Nnambu*Nspin*Norb,Nnambu*Nspin*Norb) :: mtmp
integer :: i,j
Expand All @@ -325,6 +361,9 @@ function is_diagonal_nn(mnnn) result(flag)
end function is_diagonal_nn

function is_diagonal_so(mlso) result(flag)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
complex(8),dimension(Nnambu*Nspin*Norb,Nnambu*Nspin*Norb) :: mlso
complex(8),dimension(Nnambu*Nspin*Norb,Nnambu*Nspin*Norb) :: mtmp
integer :: i,j
Expand All @@ -348,6 +387,9 @@ end function is_diagonal_so


function check_herm(A,N,error) result(bool)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
integer,intent(in) :: N
complex(8),dimension(N,N),intent(in) :: A
logical :: bool
Expand All @@ -359,6 +401,9 @@ end function check_herm


function check_nambu(A,N,error) result(bool)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
integer,intent(in) :: N
complex(8),dimension(2*N,2*N),intent(in) :: A
complex(8),dimension(N,N) :: h11,h22
Expand Down
9 changes: 9 additions & 0 deletions src/ED_BATH/ED_BATH_DMFT.f90
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ end subroutine deallocate_dmft_bath


subroutine init_dmft_bath(dmft_bath_,used)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
!
! Initialize the :f:var:`effective_bath` input :f:var:`dmft_bath_`.
! The energy parameters :f:var:`e` are constructed using a centered :f:var:`nbath` discretization of the flat band of width 2 :f:var:`ed_hw_bath`.
Expand Down Expand Up @@ -440,6 +443,9 @@ end subroutine init_dmft_bath


subroutine write_dmft_bath(dmft_bath_,unit)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
!
! Write the :f:var:`effective_bath` on input to std.output or to a file associated to the [optional] unit.
!
Expand Down Expand Up @@ -836,6 +842,9 @@ end subroutine set_dmft_bath


subroutine get_dmft_bath(dmft_bath_,bath_)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
!
! Set the user input bath :f:var:`bath_` from the components of the :f:var:`effective_bath` :f:var:`dmft_bath_` , i.e. it dumps the internal data structure to the user bath.
!
Expand Down
18 changes: 18 additions & 0 deletions src/ED_BATH/ED_BATH_FUNCTIONS.f90
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ MODULE ED_BATH_FUNCTIONS


function delta_bath_array(x,dmft_bath_,axis) result(Delta)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
complex(8),dimension(:),intent(in) :: x !complex array for the frequency
type(effective_bath) :: dmft_bath_ !the current :f:var:`effective_bath` instance
character(len=*),optional :: axis !string indicating the desired axis, :code:`'m'` for Matsubara (default), :code:`'r'` for Real-axis
Expand Down Expand Up @@ -346,6 +349,9 @@ end function delta_bath_array

!ANOMALous:
function fdelta_bath_array(x,dmft_bath_,axis) result(Fdelta)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
complex(8),dimension(:),intent(in) :: x !complex array for the frequency
type(effective_bath) :: dmft_bath_ !the current :f:var:`effective_bath` instance
complex(8),dimension(Nspin,Nspin,Norb,Norb,size(x)) :: Fdelta
Expand Down Expand Up @@ -498,6 +504,9 @@ end function fdelta_bath_array


function g0and_bath_array(x,dmft_bath_,axis) result(G0and)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
complex(8),dimension(:),intent(in) :: x !complex array for the frequency
type(effective_bath) :: dmft_bath_ !the current :f:var:`effective_bath` instance
complex(8),dimension(Nspin,Nspin,Norb,Norb,size(x)) :: G0and,Delta,Fdelta
Expand Down Expand Up @@ -683,6 +692,9 @@ end function g0and_bath_array

!ANOMALous:
function f0and_bath_array(x,dmft_bath_,axis) result(F0and)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
complex(8),dimension(:),intent(in) :: x !complex array for the frequency
type(effective_bath) :: dmft_bath_ !the current :f:var:`effective_bath` instance
complex(8),dimension(Nspin,Nspin,Norb,Norb,size(x)) :: F0and,Delta,Fdelta
Expand Down Expand Up @@ -800,6 +812,9 @@ end function f0and_bath_array


function invg0_bath_array(x,dmft_bath_,axis) result(G0and)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
complex(8),dimension(:),intent(in) :: x !complex array for the frequency
type(effective_bath) :: dmft_bath_ !the current :f:var:`effective_bath` instance
complex(8),dimension(Nspin,Nspin,Norb,Norb,size(x)) :: G0and,Delta
Expand Down Expand Up @@ -931,6 +946,9 @@ end function invg0_bath_array

!ANOMALous:
function invf0_bath_array(x,dmft_bath_,axis) result(F0and)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb,Nbath
#endif
complex(8),dimension(:),intent(in) :: x !complex array for the frequency
type(effective_bath) :: dmft_bath_ !the current :f:var:`effective_bath` instance
complex(8),dimension(Nspin,Nspin,Norb,Norb,size(x)) :: F0and,Fdelta
Expand Down
2 changes: 1 addition & 1 deletion src/ED_BATH/ED_BATH_REPLICA.f90
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ subroutine allocate_hreplica(Nsym)
integer :: Nsym
integer :: isym
!
#ifdef _DEBUG,iorb,ispin
#ifdef _DEBUG
if(ed_verbose>3)write(Logfile,"(A)")"DEBUG allocate_Hreplica"
#endif
if(allocated(Hreplica_basis))deallocate(Hreplica_basis)
Expand Down
3 changes: 3 additions & 0 deletions src/ED_MAIN.f90
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ end subroutine ed_solve_single


subroutine ed_solve_lattice(bath,mpi_lanc,Uloc_ii,Ust_ii,Jh_ii,Jp_ii,Jx_ii,iflag)
#if __INTEL_COMPILER
use ED_INPUT_VARS, only: Nspin,Norb
#endif
real(8) :: bath(:,:) !user bath input array
logical,optional :: mpi_lanc !parallelization strategy flag: if :code:`.false.` each core serially solves an inequivalent site, if :code:`.true.` all cores parallely solve each site in sequence. Default :code:`.false.` .
real(8),optional,dimension(size(bath,1),Norb) :: Uloc_ii !site-dependent values for :f:var:`uloc` , overriding the ones in the input file. It has dimension [ :f:var:`nlat` , :f:var:`norb` ].
Expand Down
20 changes: 10 additions & 10 deletions src/python/c_bindings/edi2py_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -187,91 +187,91 @@ end subroutine ed_get_eimp_n2_c
!rebuild sigma
subroutine rebuild_sigma_single_n3_c(zeta,dz,sigma_normal,sigma_anomalous) bind(c,name="build_sigma_single_n3")
use, intrinsic :: iso_c_binding
integer(c_int),value :: dz
complex(c_double_complex) :: zeta(dz)
complex(c_double_complex) :: sigma_normal(Nspin*Norb,Nspin*Norb,dz)
complex(c_double_complex) :: sigma_anomalous(Nspin*Norb,Nspin*Norb,dz)
integer(c_int),value :: dz
call ed_build_sigma(zeta,sigma_normal,sigma_anomalous)
end subroutine rebuild_sigma_single_n3_c

subroutine rebuild_sigma_single_n5_c(zeta,dz,sigma_normal,sigma_anomalous) bind(c,name="build_sigma_single_n5")
use, intrinsic :: iso_c_binding
integer(c_int),value :: dz
complex(c_double_complex) :: zeta(dz)
complex(c_double_complex) :: sigma_normal(Nspin,Nspin,Norb,Norb,dz)
complex(c_double_complex) :: sigma_anomalous(Nspin,Nspin,Norb,Norb,dz)
integer(c_int),value :: dz
call ed_build_sigma(zeta,sigma_normal,sigma_anomalous)
end subroutine rebuild_sigma_single_n5_c

subroutine rebuild_sigma_ineq_n3_c(zeta,dz,Nineq,sigma_normal,sigma_anomalous) bind(c,name="build_sigma_ineq_n3")
use, intrinsic :: iso_c_binding
integer(c_int),value :: dz,Nineq
complex(c_double_complex) :: zeta(dz)
complex(c_double_complex) :: sigma_normal(Nineq*Nspin*Norb,Nineq*Nspin*Norb,dz)
complex(c_double_complex) :: sigma_anomalous(Nineq*Nspin*Norb,Nineq*Nspin*Norb,dz)
integer(c_int),value :: dz,Nineq
call ed_build_sigma(zeta,Nineq,sigma_normal,sigma_anomalous)
end subroutine rebuild_sigma_ineq_n3_c

subroutine rebuild_sigma_ineq_n4_c(zeta,dz,Nineq,sigma_normal,sigma_anomalous) bind(c,name="build_sigma_ineq_n4")
use, intrinsic :: iso_c_binding
integer(c_int),value :: dz,Nineq
complex(c_double_complex) :: zeta(dz)
complex(c_double_complex) :: sigma_normal(Nineq,Nspin*Norb,Nspin*Norb,dz)
complex(c_double_complex) :: sigma_anomalous(Nineq,Nspin*Norb,Nspin*Norb,dz)
integer(c_int),value :: dz,Nineq
call ed_build_sigma(zeta,Nineq,sigma_normal,sigma_anomalous)
end subroutine rebuild_sigma_ineq_n4_c

subroutine rebuild_sigma_ineq_n6_c(zeta,dz,Nineq,sigma_normal,sigma_anomalous) bind(c,name="build_sigma_ineq_n6")
use, intrinsic :: iso_c_binding
integer(c_int),value :: dz,Nineq
complex(c_double_complex) :: zeta(dz)
complex(c_double_complex) :: sigma_normal(Nineq,Nspin,Nspin,Norb,Norb,dz)
complex(c_double_complex) :: sigma_anomalous(Nineq,Nspin,Nspin,Norb,Norb,dz)
integer(c_int),value :: dz,Nineq
call ed_build_sigma(zeta,Nineq,sigma_normal,sigma_anomalous)
end subroutine rebuild_sigma_ineq_n6_c

!rebuild gimp
subroutine rebuild_gimp_single_n3_c(zeta,dz,gimp_normal,gimp_anomalous) bind(c,name="build_gimp_single_n3")
use, intrinsic :: iso_c_binding
integer(c_int),value :: dz
complex(c_double_complex) :: zeta(dz)
complex(c_double_complex) :: gimp_normal(Nspin*Norb,Nspin*Norb,dz)
complex(c_double_complex) :: gimp_anomalous(Nspin*Norb,Nspin*Norb,dz)
integer(c_int),value :: dz
call ed_build_gimp(zeta,gimp_normal,gimp_anomalous)
end subroutine rebuild_gimp_single_n3_c

subroutine rebuild_gimp_single_n5_c(zeta,dz,gimp_normal,gimp_anomalous) bind(c,name="build_gimp_single_n5")
use, intrinsic :: iso_c_binding
integer(c_int),value :: dz
complex(c_double_complex) :: zeta(dz)
complex(c_double_complex) :: gimp_normal(Nspin,Nspin,Norb,Norb,dz)
complex(c_double_complex) :: gimp_anomalous(Nspin,Nspin,Norb,Norb,dz)
integer(c_int),value :: dz
call ed_build_gimp(zeta,gimp_normal,gimp_anomalous)
end subroutine rebuild_gimp_single_n5_c

subroutine rebuild_gimp_ineq_n3_c(zeta,dz,Nineq,gimp_normal,gimp_anomalous) bind(c,name="build_gimp_ineq_n3")
use, intrinsic :: iso_c_binding
integer(c_int),value :: dz,Nineq
complex(c_double_complex) :: zeta(dz)
complex(c_double_complex) :: gimp_normal(Nineq*Nspin*Norb,Nineq*Nspin*Norb,dz)
complex(c_double_complex) :: gimp_anomalous(Nineq*Nspin*Norb,Nineq*Nspin*Norb,dz)
integer(c_int),value :: dz,Nineq
call ed_build_gimp(zeta,Nineq,gimp_normal,gimp_anomalous)
end subroutine rebuild_gimp_ineq_n3_c

subroutine rebuild_gimp_ineq_n4_c(zeta,dz,Nineq,gimp_normal,gimp_anomalous) bind(c,name="build_gimp_ineq_n4")
use, intrinsic :: iso_c_binding
integer(c_int),value :: dz,Nineq
complex(c_double_complex) :: zeta(dz)
complex(c_double_complex) :: gimp_normal(Nineq,Nspin*Norb,Nspin*Norb,dz)
complex(c_double_complex) :: gimp_anomalous(Nineq,Nspin*Norb,Nspin*Norb,dz)
integer(c_int),value :: dz,Nineq
call ed_build_gimp(zeta,Nineq,gimp_normal,gimp_anomalous)
end subroutine rebuild_gimp_ineq_n4_c

subroutine rebuild_gimp_ineq_n6_c(zeta,dz,Nineq,gimp_normal,gimp_anomalous) bind(c,name="build_gimp_ineq_n6")
use, intrinsic :: iso_c_binding
integer(c_int),value :: dz,Nineq
complex(c_double_complex) :: zeta(dz)
complex(c_double_complex) :: gimp_normal(Nineq,Nspin,Nspin,Norb,Norb,dz)
complex(c_double_complex) :: gimp_anomalous(Nineq,Nspin,Nspin,Norb,Norb,dz)
integer(c_int),value :: dz,Nineq
call ed_build_gimp(zeta,Nineq,gimp_normal,gimp_anomalous)
end subroutine rebuild_gimp_ineq_n6_c

0 comments on commit 4c14463

Please sign in to comment.