Here we provide a simple fortran 90 code that implements the recursive Green’s functions techniques for calculating the self-energy of a semi-infinite lead as described in Appendix C of “Introduction to Graphene-Based Nanomaterials”. To call this routine you must provide an array with matrices containing the hoppings between the layers as well as the diagonal block matrices of the Hamiltonian.
This should serve to give you an idea of a possible implementation. Of course, this can also be done in Python for example (if you are interested just drop a line to Luis Foa Torres).
selfenergy.f90 (click to download)