Reputation: 901
My supervisor at university has tasked me with reverse-engineering some Fortran 95 code. I have struggled to find good documentation on it. There's a module that contains this:
interface get_HS_blocks
module procedure TBModel_get_HS_blocks
end interface get_HS_blocks
I was watching some videos on youtube and the guy in the videos was saying that you «interface blocks to instruct the compiler on how to behave when the datatype that is passed into a procedure can change». In this case, I guess that means that
get_HS_blocks
calls TBModel_get_HS_blocks
?But later, TBModel_get_HS_blocks
calls get_HS_blocks
itself:
subroutine TBModel_get_HS_blocks(this, at, i, j, dv_hat, dv_mag, b_H, b_S, i_mag)
type(TBModel), intent(in) :: this
type(Atoms), intent(in) :: at
integer, intent(in) :: i, j
real(dp), intent(in) :: dv_hat(3), dv_mag
real(dp), intent(out) :: b_H(:,:), b_S(:,:)
integer, intent(in), optional :: i_mag
select case(this%functional_form)
case (FF_NRL_TB)
call get_HS_blocks(this%tbmodel_nrl_tb, at, i, j, dv_hat, dv_mag, b_H, b_S, i_mag)
case (FF_Bowler)
call get_HS_blocks(this%tbmodel_bowler, at, i, j, dv_hat, dv_mag, b_H, b_S, i_mag)
case (FF_DFTB)
call get_HS_blocks(this%tbmodel_dftb, at, i, j, dv_hat, dv_mag, b_H, b_S, i_mag)
case (FF_GSP)
call get_HS_blocks(this%tbmodel_gsp, at, i, j, dv_hat, dv_mag, b_H, b_S)
case default
call system_abort ('TBModel_get_HS_blocks confused by functional_form' // this%functional_form)
end select
end subroutine
So if (1) above was correct, get_HS_blocks
would be recursively called indefinitely ?!
Can you briefly explain what module procedure does inside the interface block, and what happens when get_HS_blocks
calls TBModel_get_HS_block
?
Upvotes: 0
Views: 38