Repository: dftbplus/dftbplus
Pull request #1650: Minor phonons line length and source formatting
Author: login: bhourahine
Labels: name: transport
description: DFTB+ side of transport calculations
Created: 2025-03-09T09:50:33Z | Merged: 2025-03-12T15:45:08Z

Cleans up a few mismatches against the style guide.


Diff:
diff --git a/app/phonons/initphonons.F90 b/app/phonons/initphonons.F90
index f1281c26b5..93a814cdb1 100644
--- a/app/phonons/initphonons.F90
+++ b/app/phonons/initphonons.F90
@@ -18,8 +18,8 @@ module phonons_initphonons
   use dftbp_common_unitconversion, only : energyUnits, lengthUnits
   use dftbp_dftb_periodic, only : getCellTranslations, getNrOfNeighboursForAll, getSuperSampling,&
       & TNeighbourList, TNeighbourlist_init, updateNeighbourList
-  use dftbp_extlibs_xmlf90, only : assignment(=), char, destroyNodeList, fnode, fnodelist, getItem1,&
-      & getLength, getNodeName, string, textNodeName
+  use dftbp_extlibs_xmlf90, only : assignment(=), char, destroyNodeList, fnode, fnodelist,&
+      & getItem1, getLength, getNodeName, string, textNodeName
   use dftbp_io_charmanip, only : i2c, tolower, unquote
   use dftbp_io_hsdparser, only : dumpHSD, parseHSD
   use dftbp_io_hsdutils, only : detailedError, getChild, getChildren, getChildValue,&
@@ -67,7 +67,7 @@ module phonons_initphonons
   !> Container of tunneling parameters
   type(TNEGFtundos), public :: tundos
 
-  !> verbose flag
+  !> Verbose flag
   logical, public :: tVerbose
 
   !> Core Variables
@@ -80,16 +80,16 @@ module phonons_initphonons
   real(dp), allocatable, public :: kPoint(:,:), kWeight(:)
   integer, public :: nKPoints
 
-  !> maps atom index in central cell
+  !> Maps atom index in central cell
   integer, allocatable, public  :: Img2CentCell(:)
 
-  !> neighbor list
+  !> Neighbor list
   type(TNeighbourList), public :: neighbourList
 
-  !> number of neighbors
+  !> Number of neighbors
   integer, allocatable, target, public :: nNeighbour(:)
 
-  !> cutoff for Hessian
+  !> Cutoff for Hessian
   real(dp), public :: cutoff
 
   !> Temperature range
@@ -98,7 +98,7 @@ module phonons_initphonons
   !> Modes to analyze (e.g., longitudinal, transverse, in-plane, etc)
   integer, public :: selTypeModes
 
-  !> order=2 means harmonic, 3 is anharmonic 3rd order, etc.
+  !> Order=2 means harmonic, 3 is anharmonic 3rd order, etc.
   integer, public :: order
 
   !> Atomic temperature
@@ -119,16 +119,16 @@ module phonons_initphonons
   !>
   logical, public :: tTransport
 
-  !> whether phonon dispersions should be computed
+  !> Whether phonon dispersions should be computed
   logical, public :: tPhonDispersion
 
-  !> number of repeated cells along lattice vectors
+  !> Number of repeated cells along lattice vectors
   integer, public :: nCells(3)
 
-  !> whether phonon dispersions should be computed
+  !> Whether phonon dispersions should be computed
   character(4), public :: outputUnits
 
-  !> whether taggedoutput should be written
+  !> Whether taggedoutput should be written
   logical, public :: tWriteTagged
 
   !> Which phonon modes to animate
@@ -137,59 +137,60 @@ module phonons_initphonons
   !> Number of phonon modes to animate
   integer, public :: nModesToPlot
 
-  !> number of cycles in mode animation
+  !> Number of cycles in mode animation
   integer, public :: nCycles
 
-  !> number of steps in mode animation
+  !> Number of steps in mode animation
   integer, public, parameter :: nSteps = 10
 
   !> Version of the current parser
   integer, parameter :: parserVersion = 4
 
-  !> Version of the oldest parser, for which compatibility is maintained
+  !> Version of the oldest parser for which compatibility is maintained
   integer, parameter :: minVersion = 4
 
 
   !> Container type for parser related flags.
   type TParserFlags
 
-    !> stop after parsing?
+    !> Stop after parsing?
     logical :: tStop
 
     !> Continue despite unprocessed nodes
     logical :: tIgnoreUnprocessed
 
-    !> write parsed HSD input
+    !> Write parsed HSD input
     logical :: tWriteHSD
 
-    !> write TaggedOutput
+    !> Write TaggedOutput
 
     logical :: tWriteTagged
   end type TParserFlags
 
 
-  !> constants parameters
+  !> Constants parameters
   type TModeEnum
-    !> along x,y,z
+    !> Along x,y,z
     integer :: ALLMODES = 0
-    !> along x
+    !> Along x
     integer :: XX = 1
-    !> along y
+    !> Along y
     integer :: YY = 2
-    !> along z
+    !> Along z
     integer :: ZZ = 3
-    !> along z (assume transport along z)
+    !> Along z (assume transport along z)
     integer :: LONGITUDINAL = 4
-    !> along x,y
+    !> Along x,y
     integer :: TRANSVERSE = 5
-    !> along x,z (assume 2D structure in x-z)
+    !> Along x,z (assume 2D structure in x-z)
     integer :: INPLANE = 6
-    !> along y
+    !> Along y
     integer :: OUTOFPLANE = 7
   end type TModeEnum
 
   type(TModeEnum), public, parameter :: modeEnum = TModeEnum()
 
+
 contains
 
   !> Initialise program variables
@@ -409,15 +410,12 @@ subroutine readOptions(node, root, flags)
     type(fnode), pointer :: child
 
     !! Check if input needs compatibility conversion.
-    call getChildValue(node, "ParserVersion", inputVersion, parserVersion, &
-        &child=child)
+    call getChildValue(node, "ParserVersion", inputVersion, parserVersion, child=child)
     if (inputVersion < 1 .or. inputVersion > parserVersion) then
-      call detailedError(child, "Invalid parser version (" // i2c(inputVersion)&
-          &// ")")
+      call detailedError(child, "Invalid parser version (" // i2c(inputVersion) // ")")
     elseif (inputVersion < minVersion) then
-      call detailedError(child, &
-          &"Sorry, no compatibility mode for parser version " &
-          &// i2c(inputVersion) // " (too old)")
+      call detailedError(child, "Sorry, no compatibility mode for parser version "&
+          & // i2c(inputVersion) // " (too old)")
     end if
 
     call getChildValue(node, "WriteAutotestTag", tWriteTagged, .false.)
@@ -430,11 +428,14 @@ subroutine readOptions(node, root, flags)
 
   end subroutine readOptions
 
-  !!* Read in the geometry stored as xml in internal or gen format.
-  !!* @param geonode Node containing the geometry
-  !!* @param geo     Contains the geometry information on exit
+
+  !> Read in the geometry stored as xml in internal or gen format.
   subroutine readGeometry(geonode, geo)
+
+    !> Node containing the geometry
     type(fnode), pointer :: geonode
+
+    !> Contains the geometry information on exit
     type(TGeometry), intent(out) :: geo
 
     type(fnode), pointer :: child, value
@@ -459,7 +460,8 @@ subroutine readGeometry(geonode, geo)
 
   end subroutine readGeometry
 
-  !!* Read geometry information for transport calculation
+
+  !> Read geometry information for transport calculation
   subroutine readTransportGeometry(root, geom, tp)
     type(fnode), pointer :: root
     type(TGeometry), intent(inout) :: geom
@@ -493,6 +495,7 @@ subroutine readTransportGeometry(root, geom, tp)
 
   end subroutine readTransportGeometry
 
+
   !> Reads settings for the first layer atoms in principal layers
   subroutine readFirstLayerAtoms(pnode, pls, npl, idxdevice, check)
 
@@ -539,7 +542,8 @@ subroutine readFirstLayerAtoms(pnode, pls, npl, idxdevice, check)
 
   end subroutine readFirstLayerAtoms
 
-   !> Read bias information, used in Analysis and Green's function solver
+
+  !> Read bias information, used in Analysis and Green's function solver
   subroutine readContacts(pNodeList, contacts, geom, upload)
     type(fnodeList), pointer :: pNodeList
     type(ContactInfo), allocatable, dimension(:), intent(inout) :: contacts
@@ -607,9 +611,9 @@ subroutine readContacts(pNodeList, contacts, geom, upload)
 
   end subroutine readContacts
 
-      ! Sanity checking of atom ranges and returning contact vector and direction.
-  subroutine getContactVectorII(atomrange, geom, id, pContact, plShiftTol, &
-      &contactVec, contactDir)
+
+  !> Verification checking of atom ranges and returning contact vector and direction.
+  subroutine getContactVectorII(atomrange, geom, id, pContact, plShiftTol, contactVec, contactDir)
     integer, intent(in) :: atomrange(2)
     type(TGeometry), intent(in) :: geom
     integer, intent(in) :: id
@@ -661,6 +665,7 @@ subroutine getContactVectorII(atomrange, geom, id, pContact, plShiftTol, &
 
   end subroutine getContactVectorII
 
+
   !> Used to read atomic masses from SK files
   subroutine readSKfiles(child, geo, speciesMass)
     type(fnode), pointer :: child
@@ -750,6 +755,7 @@ subroutine readSKfiles(child, geo, speciesMass)
 
   end subroutine readSKfiles
 
+
   subroutine readMasses(value, geo, speciesMass)
     type(fnode), pointer :: value
     type(TGeometry), intent(in) :: geo
@@ -773,6 +779,7 @@ subroutine readMasses(value, geo, speciesMass)
 
   end subroutine readMasses
 
+
   !> K-Points
   subroutine readKPoints(node, geo, tBadIntegratingKPoints)
 
@@ -921,6 +928,7 @@ subroutine readKPoints(node, geo, tBadIntegratingKPoints)
 
   end subroutine readKPoints
 
+
   subroutine  readKPointsFile(child)
     type(fnode),  pointer ::  child
     type(string) :: text
@@ -930,6 +938,7 @@ subroutine  readKPointsFile(child)
 
   end subroutine  readKPointsFile
 
+
   subroutine readKPointsFile_help(child,text)
     type(fnode),  pointer ::  child
     character(len=*), intent(in) :: text
@@ -963,13 +972,13 @@ end subroutine readKPointsFile_help
 
 
   !>  Read DFTB hessian.
-  !>
-  !> The derivatives matrix must be stored as the following order:
-  !>  For the x y z directions of atoms 1..n
-  !>    d^2 E        d^2 E       d^2 E       d^2 E        d^2 E
-  !>  ---------- + --------- + --------- + ---------- + ---------- +...
-  !>  dx_1 dx_1    dy_1 dx_1   dz_1 dx_1   dx_2 dx_1    dy_2 dx_1
-  !>
+  !!
+  !! The derivatives matrix must be stored in the following order:
+  !!  For the x y z directions of atoms 1..n
+  !!    d^2 E        d^2 E       d^2 E       d^2 E        d^2 E
+  !!  ---------- + --------- + --------- + ---------- + ---------- +...
+  !!  dx_1 dx_1    dy_1 dx_1   dz_1 dx_1   dx_2 dx_1    dy_2 dx_1
+  !!
   subroutine readDftbHessian(child)
     type(fnode), pointer :: child
 
@@ -1025,6 +1034,7 @@ subroutine readDftbHessian(child)
 
   end subroutine readDftbHessian
 
+
   subroutine readDynMatrix(child)
     type(fnode), pointer :: child
 
@@ -1035,12 +1045,12 @@ subroutine readDynMatrix(child)
     nDerivs = 3 * nMovedAtom
     allocate(dynMatrix(nDerivs,nDerivs))
 
-    !The derivatives matrix must be stored as the following order:
-
-    ! For the x y z directions of atoms 1..n
-    !   d^2 E        d^2 E       d^2 E       d^2 E        d^2 E
-    ! ---------- + --------- + --------- + ---------- + ---------- +...
-    ! dx_1 dx_1    dy_1 dx_1   dz_1 dx_1   dx_2 dx_1    dy_2 dx_1
+    !! The derivatives matrix must be stored as the following order:
+    !!
+    !! For the x y z directions of atoms 1..n
+    !!   d^2 E        d^2 E       d^2 E       d^2 E        d^2 E
+    !! ---------- + --------- + --------- + ---------- + ---------- +...
+    !! dx_1 dx_1    dy_1 dx_1   dz_1 dx_1   dx_2 dx_1    dy_2 dx_1
 
     write(stdOut, "(/, A)") "read dynamical matrix..."
 
@@ -1056,6 +1066,7 @@ subroutine readDynMatrix(child)
 
   end subroutine readDynMatrix
 
+
   subroutine readCp2kHessian(child)
     type(fnode), pointer :: child
 
@@ -1083,12 +1094,12 @@ subroutine readCp2kHessian(child)
       call detailedError(child,"Hessian file "//trim(char(filename))//" does not exist")
     end if
 
-    !The derivatives matrix must be stored as the following order:
-
-    ! For the x y z directions of atoms 1..n
-    !   d^2 E        d^2 E       d^2 E       d^2 E        d^2 E
-    ! ---------- + --------- + --------- + ---------- + ---------- +...
-    ! dx_1 dx_1    dy_1 dx_1   dz_1 dx_1   dx_2 dx_1    dy_2 dx_1
+    !! The derivatives matrix must be stored as the following order:
+    !!
+    !! For the x y z directions of atoms 1..n
+    !!   d^2 E        d^2 E       d^2 E       d^2 E        d^2 E
+    !! ---------- + --------- + --------- + ---------- + ---------- +...
+    !! dx_1 dx_1    dy_1 dx_1   dz_1 dx_1   dx_2 dx_1    dy_2 dx_1
 
     nBlocks = nDerivs/5.0
     allocate(HessCp2k(nDerivs*nBlocks,5))
@@ -1126,8 +1137,9 @@ subroutine readCp2kHessian(child)
 
   end subroutine readCp2kHessian
 
-  ! Subroutine removing entries in the Dynamical Matrix.
-  ! Not used because identified as a wrong way
+
+  !> Subroutine removing entries in the Dynamical Matrix.
+  !! Not used because identified as a wrong way
   subroutine selectModes()
 
     integer :: iCount, jCount, ii, jj, kk, ll
@@ -1169,7 +1181,8 @@ subroutine selectModes()
 
   end subroutine selectModes
 
-  !! Reads the Analysis block.
+
+  !> Reads the Analysis block.
   subroutine readAnalysis(node, geo, pdos, tundos, transpar, atTemperature)
     type(fnode), pointer :: node, pnode
     type(TGeometry), intent(in) :: geo
@@ -1215,6 +1228,7 @@ subroutine readAnalysis(node, geo, pdos, tundos, transpar, atTemperature)
 
   end subroutine readAnalysis
 
+
   subroutine readPDOSRegions(children, geo, iAtInregion, regionLabels)
     type(fnodeList), pointer :: children
     type(TGeometry), intent(in) :: geo
@@ -1243,12 +1257,13 @@ subroutine readPDOSRegions(children, geo, iAtInregion, regionLabels)
 
   end subroutine readPDOSRegions
 
-  !!* Read Tunneling and Dos options from analysis block
-  !!* tundos is the container to be filled
-  !!* ncont is needed for contact option allocation
+
+  !> Read Tunneling and Dos options from analysis block
   subroutine readTunAndDos(root, geo, tundos, transpar, temperature)
     type(fnode), pointer :: root
     type(TGeometry), intent(in) :: geo
+
+    !> The container to be filled
     type(TNEGFTunDos), intent(inout) :: tundos
     type(TTransPar), intent(inout) :: transpar
     real(dp), intent(in) :: temperature
@@ -1376,7 +1391,8 @@ end subroutine addAtomResolvedRegion
 
   end subroutine readTunAndDos
 
-  ! Get contacts for terminal currents by name
+
+  !> Get contacts for terminal currents by name
   subroutine getEmitterCollectorByName(pNode, emitter, collector, contactNames)
     type(fnode), pointer :: pNode
     integer, intent(out) :: emitter, collector
@@ -1400,7 +1416,8 @@ subroutine getEmitterCollectorByName(pNode, emitter, collector, contactNames)
 
   end subroutine getEmitterCollectorByName
 
-  ! Getting the contact by name
+
+  !> Getting the contact by name
   function getContactByName(contactNames, contName, pNode) result(contact)
     character(len=*), intent(in) :: contactNames(:)
     character(len=*), intent(in) :: contName
@@ -1423,7 +1440,8 @@ function getContactByName(contactNames, contName, pNode) result(contact)
 
   end function getContactByName
 
-  ! Set model for w-dependent delta in G.F.
+
+  !> Set model for w-dependent delta in G.F.
   subroutine readDeltaModel(root, tundos)
     type(fnode), pointer :: root
     type(TNEGFTunDos), intent(inout) :: tundos
@@ -1463,8 +1481,9 @@ subroutine readDeltaModel(root, tundos)
     end select
   end subroutine ReadDeltaModel
 
-  ! Build a simple neighbor list. Currently does not work for periodic systems.
-  ! Have to fix this important point
+
+  !> Build a simple neighbor list. Currently does not work for periodic systems.
+  !! Have to fix this important point
   subroutine buildNeighbourList()
 
     integer ::  iAtom, jAtom, ii, jj, kk, PL1, PL2
@@ -1527,6 +1546,7 @@ subroutine buildNeighbourList()
 
   end subroutine buildNeighbourList
 
+
   subroutine cutDynMatrix()
 
     integer :: iAtom, jAtom, jj
@@ -1553,6 +1573,7 @@ subroutine cutDynMatrix()
 
   end subroutine cutDynMatrix
 
+
   function getPL(iAt) result(PL)
     integer, intent(in) :: iAt
     integer :: PL
@@ -1573,7 +1594,8 @@ function getPL(iAt) result(PL)
 
   end function getPL
 
-  !> select family of modes to analyze and restrict transmission
+
+  !> Select family of modes to analyze and restrict transmission
   subroutine setTypeOfModes(root, transpar)
     type(fnode), pointer :: root
     type(TTransPar), intent(inout) :: transpar
@@ -1611,8 +1633,9 @@ subroutine setTypeOfModes(root, transpar)
 
   end subroutine setTypeOfModes
 
+
   !> Check that the geometry orientation is consistent with selTypeModes
-  !> Currently only checks that transport direction is along z
+  !! Currently only checks that transport direction is along z
   subroutine checkTypeOfModes(root, tp)
     type(fnode), pointer :: root
     type(TTransPar), intent(inout) :: tp
@@ -1627,7 +1650,8 @@ subroutine checkTypeOfModes(root, tp)
 
   end subroutine checkTypeOfModes
 
-  ! check that transport direction is along z
+
+  !> Check that transport direction is along z
   subroutine checkAlongZ(root, tp)
     type(fnode), pointer :: root
     type(TTransPar), intent(inout) :: tp
@@ -1644,8 +1668,8 @@ subroutine checkAlongZ(root, tp)
         call detailedError(root,"Transport direction is not along z")
       end if
     end do
-  end subroutine checkAlongZ
 
+  end subroutine checkAlongZ
 
 
 end module phonons_initphonons
diff --git a/app/phonons/libnegfint.F90 b/app/phonons/libnegfint.F90
index 8e8699ff71..c703b2d63e 100644
--- a/app/phonons/libnegfint.F90
+++ b/app/phonons/libnegfint.F90
@@ -26,7 +26,6 @@
 #:include "common.fypp"
 
 module phonons_libnegfint
-  use phonons_initphonons, only : modeEnum, TempMax, TempMin, TempStep
   use dftbp_common_accuracy, only : dp
   use dftbp_common_environment, only : TEnvironment
   use dftbp_common_file, only : closeFile, openFile, TFileDescr
@@ -48,6 +47,7 @@ module phonons_libnegfint
   use dftbp_extlibs_mpifx, only : MPI_SUM, mpifx_comm, mpifx_reduceip
   use dftbp_extlibs_negf, only : negf_mpi_init
 #:endif
+  use phonons_initphonons, only : modeEnum, TempMax, TempMin, TempStep
   implicit none
   private
 
@@ -58,7 +58,7 @@ module phonons_libnegfint
 
   public :: negf_init, negf_destroy
 
-  !> initialize tunneling projection on specific modes
+  !> Initialize tunneling projection on specific modes
   public :: init_tun_proj
 
   ! This initializes the partitioned structure
@@ -73,23 +73,16 @@ module phonons_libnegfint
   ! direct calls to compute phonon current
   public :: negf_phonon_current
 
-  ! interface csr matrices. The pattern structure of csrHam
-  ! is defined by negf_init_csr.
-  ! Not needed since dnamical matrix is stored dense
-  !public :: negf_init_csr
+  ! interface csr matrices. The pattern structure of csrHam is defined by negf_init_csr.
 
   type(z_CSR), target :: csrHam
   type(Z_CSR), pointer :: pCsrHam => null()
 
-  !type(z_CSR),target :: csrOver ! need to be removed
-  !type(Z_CSR), pointer :: pCsrOver => null()
 
+contains
 
-  contains
 
-!------------------------------------------------------------------------------
-! Init gDFTB environment and variables
-!------------------------------------------------------------------------------
+  !> Init gDFTB environment and variables
   subroutine negf_init(env, transpar, tundos, initinfo)
 
     !> Environment settings, suplying the global comm world
@@ -98,10 +91,10 @@ subroutine negf_init(env, transpar, tundos, initinfo)
     !> Parameters for the transport calculation
     Type(TTranspar), intent(in) :: transpar
 
-    !> parameters for tuneling and density of states evaluation
+    !> Parameters for tuneling and density of states evaluation
     Type(TNEGFTunDos), intent(in) :: tundos
 
-    !> initialization flag
+    !> Initialization flag
     logical, intent(out) :: initinfo
 
 
@@ -116,9 +109,9 @@ subroutine negf_init(env, transpar, tundos, initinfo)
 
     pNegf=>negf
 
-#:if WITH_MPI
+  #:if WITH_MPI
     call negf_mpi_init(env%mpi%globalComm, tIOproc)
-#:endif
+  #:endif
 
     if (transpar%defined) then
       ncont = transpar%ncont
@@ -126,18 +119,16 @@ subroutine negf_init(env, transpar, tundos, initinfo)
       ncont = 0
     endif
 
-    ! ------------------------------------------------------------------------------
-    !! Set defaults and fill up the parameter structure with them
+    ! Set defaults and fill up the parameter structure with them
     call init_negf(negf)
     call init_contacts(negf, ncont)
     call get_params(negf, parms)
     call set_scratch(negf, ".")
 
-    ! ------------------------------------------------------------------------------
     !                        SETTING CONTACT TEMPERATURES
-    ! ------------------------------------------------------------------------------
     ! If no contacts => no transport,
     if (transpar%defined) then
+
       do i = 1, ncont
         if (transpar%contacts(i)%kbT .ge. 0.0_dp) then
           parms%kbT_t(i) = transpar%contacts(i)%kbT
@@ -149,20 +140,16 @@ subroutine negf_init(env, transpar, tundos, initinfo)
       do i=1, ncont
          parms%FictCont(i) = transpar%contacts(i)%wideBand
          parms%contact_DOS(i) = transpar%contacts(i)%wideBandDOS
-      enddo
+       enddo
+
     end if
 
-    ! ------------------------------------------------------------------------------
     ! This parameter is used to set the averall drop threshold in libnegf
     ! It affects especially transmission that is not accurate more than
     ! this value.
     call set_drop(1.d-20)
 
-
-    ! ------------------------------------------------------------------------------
     !                    SETTING TRANSMISSION PARAMETERS
-    ! ------------------------------------------------------------------------------
-
     if (tundos%defined) then
       parms%verbose = tundos%verbose
       select case (tundos%deltaModel)
@@ -214,6 +201,7 @@ subroutine negf_init(env, transpar, tundos, initinfo)
 
   end subroutine negf_init
 
+
   subroutine init_tun_proj(selTypeModes, nAtoms)
     integer, intent(in) :: selTypeModes
     integer, intent(in) :: nAtoms
@@ -275,35 +263,34 @@ subroutine init_tun_proj(selTypeModes, nAtoms)
 
   end subroutine init_tun_proj
 
-  !------------------------------------------------------------------------------
+
   subroutine negf_destroy()
 
     write(stdOut, *)
     write(stdOut, *) 'Release NEGF memory:'
     call destruct(csrHam)
-    !call destruct(csrOver)
     call destroy_negf(negf)
     call writePeakInfo(stdOut)
     call writeMemInfo(stdOut)
 
   end subroutine negf_destroy
 
-  !------------------------------------------------------------------------------
+
   subroutine negf_init_str(nAtoms, transpar, iNeigh, nNeigh, img2CentCell)
 
-    !> number of atoms
+    !> Number of atoms
     integer, intent(in) :: nAtoms
 
-    !> transport calculation parameters
+    !> Transport calculation parameters
     Type(TTranspar), intent(in) :: transpar
 
-    !> neighbours of each atom
+    !> Neighbours of each atom
     Integer, intent(in) :: iNeigh(0:,:)
 
-    !> number of neighbours for each atom
+    !> Number of neighbours for each atom
     Integer, intent(in) :: nNeigh(:)
 
-    !> mapping from image atoms to central cell
+    !> Mapping from image atoms to central cell
     Integer, intent(in) :: img2CentCell(:)
 
     Integer, allocatable :: PL_end(:), cont_end(:), surf_start(:), surf_end(:), cblk(:), ind(:)
@@ -427,9 +414,8 @@ end subroutine negf_init_str
   !
   !end subroutine negf_init_phph
 
-  !------------------------------------------------------------------------------
-  ! INTERFACE subroutine to call phonon current computation
-  !------------------------------------------------------------------------------
+
+  !> INTERFACE subroutine to call phonon current computation
   subroutine calc_phonon_current(env, DynMat, tunnMat, ldosMat, &
                         & currLead, conductance, twriteTunn, twriteLDOS)
 
@@ -439,22 +425,22 @@ subroutine calc_phonon_current(env, DynMat, tunnMat, ldosMat, &
     !> The dynamical matrix of the system
     real(dp), intent(in) :: DynMat(:,:)
 
-    !> matrix of tunnelling amplitudes at each energy from contacts
+    !> Matrix of tunnelling amplitudes at each energy from contacts
     real(dp), allocatable, intent(inout) :: tunnMat(:,:)
 
-    !> density of states for each energy and region of projection
+    !> Density of states for each energy and region of projection
     real(dp), allocatable, intent(inout) :: ldosMat(:,:)
 
-    !> current into/out of contacts
+    !> Current into/out of contacts
     real(dp), allocatable, intent(inout) :: currLead(:)
 
-    !> thermal conductance
+    !> Thermal conductance
     real(dp), allocatable, intent(inout) :: conductance(:, :)
 
-    !> should tunneling data be written
+    !> Should tunneling data be written
     logical, intent(in) :: tWriteTunn
 
-    !> should DOS data be written
+    !> Should DOS data be written
     logical, intent(in) :: tWriteLDOS
 
     ! locals
@@ -509,23 +495,23 @@ subroutine calc_phonon_current(env, DynMat, tunnMat, ldosMat, &
        endif
        currLead(:) = currLead + currPVec
 
-#:if WITH_MPI
+     #:if WITH_MPI
        call add_partial_results(env%mpi%groupComm, tunnPMat, tunnMat, tunnSKRes, iK, nK)
        call add_partial_results(env%mpi%groupComm, ldosPMat, ldosMat, ldosSKRes, iK, nK)
-#:else
+     #:else
        call add_partial_results(tunnPMat, tunnMat, tunnSKRes, iK, nK)
        call add_partial_results(ldosPMat, ldosMat, ldosSKRes, iK, nK)
-#:endif
+     #:endif
 
     end do
 
-       ! MPI Reduce K dependent stuff
-#:if WITH_MPI
+    ! MPI Reduce k-dependent stuff
+  #:if WITH_MPI
     call mpifx_reduceip(env%mpi%groupComm, currLead, MPI_SUM)
     call mpifx_reduceip(env%mpi%interGroupComm, currLead, MPI_SUM)
     call add_k_results(env%mpi%interGroupComm, tunnMat, tunnSKRes )
     call add_k_results(env%mpi%interGroupComm, ldosMat, ldosSKRes )
-#:endif
+  #:endif
 
     ! converts from internal atomic units into W
     currLead = currLead * convertHeatCurrent(HessianUnits, HeatCurrUnits)
@@ -606,19 +592,19 @@ subroutine negf_phonon_current(HH, qpoint, wght, tunn, ledos, currents)
     !> Hessian
     type(z_CSR), pointer, intent(in) :: HH
 
-    !> phonon kpoint
-    integer, intent(in) :: qpoint        ! kp index
+    !> Phonon kpoint (kp index)
+    integer, intent(in) :: qpoint
 
-    !> phonon k-weight
-    real(dp), intent(in) :: wght      ! kp weight
+    !> Phonon k-weight (kp weight)
+    real(dp), intent(in) :: wght
 
     !> Tunneling
     real(dp), dimension(:,:), pointer :: tunn
 
-    !> local or projected dos
+    !> Local or projected dos
     real(dp), dimension(:,:), pointer :: ledos
 
-    !> heat currents
+    !> Heat currents
     real(dp), dimension(:), pointer :: currents
 
     type(lnParams) :: params
@@ -670,8 +656,8 @@ subroutine printH(fu, H)
 
   end subroutine printH
 
-  !----------------------------------------------------------------------------
-  !> utility to allocate and sum partial results from different channels
+
+  !> Utility to allocate and sum partial results from different channels
 #:if WITH_MPI
   subroutine add_partial_results(mpicomm, pMat, matTot, matSKRes, iK, nK)
 
@@ -681,19 +667,19 @@ subroutine add_partial_results(mpicomm, pMat, matTot, matSKRes, iK, nK)
   subroutine add_partial_results(pMat, matTot, matSKRes, iK, nK)
 #:endif
 
-    !> pointer to matrix of data
+    !> Pointer to matrix of data
     real(dp), intent(in), pointer :: pMat(:,:)
 
-    !> sum total
+    !> Sum total
     real(dp), allocatable, intent(inout) :: matTot(:,:)
 
-    !> k-resolved sum
+    !> Sum resolved by k
     real(dp), allocatable, intent(inout)  :: matSKRes(:,:,:)
 
-    !> particular k-point
+    !> Particular k-point
     integer, intent(in) :: iK
 
-    !> number of k-points
+    !> Number of k-points
     integer, intent(in) :: nK
 
     #:if WITH_MPI
@@ -738,16 +724,16 @@ subroutine add_partial_results(pMat, matTot, matSKRes, iK, nK)
 
           matSKRes(:,:,:) = 0.0_dp
         endif
-#:if WITH_MPI
+      #:if WITH_MPI
         matSKRes(:,:,iK) = tmpMat
-#:else
+      #:else
         matSKRes(:,:,iK) = pMat
-#:endif
+      #:endif
       end if
 
-#:if WITH_MPI
+    #:if WITH_MPI
       deallocate(tmpMat)
-#:endif
+    #:endif
 
     end if
 
@@ -755,19 +741,18 @@ end subroutine add_partial_results
 
 
 
-  !----------------------------------------------------------------------------
-
 #:if WITH_MPI
-  !> utility to sum up partial results over K communicator
+
+  !> Utility to sum up partial results over K communicator
   subroutine add_k_results(kcomm, mat, matSKRes)
 
     !> MPI communicator
     type(mpifx_comm), intent(in) :: kcomm
 
-    !> sum total
+    !> Sum total
     real(dp), allocatable, intent(inout) :: mat(:,:)
 
-    !> k-resolved sum
+    !> Sum resolved by k
     real(dp), allocatable, intent(inout)  :: matSKRes(:,:,:)
 
     if (allocated(mat)) then
@@ -779,8 +764,10 @@ subroutine add_k_results(kcomm, mat, matSKRes)
     endif
 
   end subroutine add_k_results
+
 #:endif
 
+
   !----------------------------------------------------------------------------
   ! init_csr: is needed only if H and S are stored in dftb+ format
   !----------------------------------------------------------------------------
@@ -827,7 +814,7 @@ subroutine write_file(negf, pTot, pKRes, filename, kpoints, kWeights)
     !> The k-point resolved data, if allocated
     real(dp), allocatable, intent(in) :: pKRes(:,:,:)
 
-    !> file to print out to
+    !> File to print out to
     character(*), intent(in) :: filename
 
     !> The k-points for the system
@@ -879,9 +866,8 @@ subroutine write_file(negf, pTot, pKRes, filename, kpoints, kWeights)
 
   end subroutine write_file
 
-  !----------------------------------------------------------------------------
-  ! DEBUG routine dumping H and S on file in Matlab format
-  !----------------------------------------------------------------------------
+
+  !> DEBUG routine dumping H and S on file in Matlab format
   subroutine negf_dumpHS(HH,SS)
     type(z_CSR), intent(in) :: HH, SS
 
diff --git a/app/phonons/phonons.F90 b/app/phonons/phonons.F90
index 9a7a2ee7ae..29da01deab 100644
--- a/app/phonons/phonons.F90
+++ b/app/phonons/phonons.F90
@@ -8,12 +8,6 @@
 #:include 'common.fypp'
 
 program phonons
-  use phonons_initphonons, only : atomicMasses, autotestTag, destructProgramVariables, dynMatrix,&
-      & geo, img2CentCell, iMovedAtoms, initProgramVariables, kPoint, modesToPlot, nAtomUnitCell,&
-      & nCells, nCycles, neighbourList, nKPoints, nModesToPlot, nMovedAtom, nNeighbour, nSteps,&
-      & outputUnits, selTypeModes, tAnimateModes, tCompModes, tPhonDispersion, tPlotModes, transpar,&
-      & tTransport, tundos, tWriteTagged, tXmakeMol
-  use phonons_libnegfint, only : calc_phonon_current, init_tun_proj, negf_init, negf_init_str
   use dftbp_common_accuracy, only : dp, lc
   use dftbp_common_constants, only : Bohr__AA, Hartree__cm, Hartree__eV, Hartree__J, hbar, pi
   use dftbp_common_environment, only : TEnvironment, TEnvironment_init
@@ -23,6 +17,12 @@ program phonons
   use dftbp_io_taggedoutput, only : TTaggedWriter, TTaggedWriter_init
   use dftbp_math_eigensolver, only : heev
   use dftbp_math_simplealgebra, only : invert33
+  use phonons_initphonons, only : atomicMasses, autotestTag, destructProgramVariables, dynMatrix,&
+      & geo, img2CentCell, iMovedAtoms, initProgramVariables, kPoint, modesToPlot, nAtomUnitCell,&
+      & nCells, nCycles, neighbourList, nKPoints, nModesToPlot, nMovedAtom, nNeighbour, nSteps,&
+      & outputUnits, selTypeModes, tAnimateModes, tCompModes, tPhonDispersion, tPlotModes,&
+      & transpar, tTransport, tundos, tWriteTagged, tXmakeMol
+  use phonons_libnegfint, only : calc_phonon_current, init_tun_proj, negf_init, negf_init_str
   implicit none
 
   type(TEnvironment) :: env
@@ -43,7 +43,7 @@ program phonons
   nProcs = 1
   write(stdOut,*)'Computing environment'
 #:if WITH_MPI
-  print*,env%mpi%globalComm%rank, env%mpi%globalComm%size, tIOProc, env%mpi%globalComm%lead
+  write(*,*)env%mpi%globalComm%rank, env%mpi%globalComm%size, tIOProc, env%mpi%globalComm%lead
   nProcs = env%mpi%globalComm%size
 #:else
   write(stdOut,*)'Not compiled with MPI enabled'
@@ -99,12 +99,14 @@ subroutine printHeader()
     write (stdOut, "(A,/)") repeat("=", 80)
     write (stdOut, "(A)") ""
     write (stdOut, "(A)") "Version 0.1"
-    write (stdOut, "(A)") "A tool to compute phonon transmission in nanostructures based on Hessians"
+    write (stdOut, "(A)") "A tool to compute phonon transmission in nanostructures based on&
+        & Hessians"
     write (stdOut, "(A)") "Authors: Alessandro Pecchia, Leonardo Medrano Sandonas"
     write (stdOut, "(A)") "When using this code, please cite this work:"
     write (stdOut, "(A)") "Leonardo Medrano Sandonas, Rafaei Gutierrez, Alessandro Pecchia,"
     write (stdOut, "(A)") "Alexander Croy, Gianaurelio Cuniberti, Quantum phonon transport in"
-    write (stdOut, "(A)") "nanomaterials: combining atomistic with non-equilibrium Green's functions"
+    write (stdOut, "(A)") "nanomaterials: combining atomistic with non-equilibrium Green's&
+        & functions"
     write (stdOut, "(A)") "techniques, Entropy 21, 735 (2019)"
     write (stdOut, "(A)") ""
   end subroutine printHeader


Reviews:
user: login: jubich
body: Looks good, but a few small changes may be necessary. If you want, you can additionally revise all comments and capitalize them.
state: CHANGES_REQUESTED
author_association: MEMBER
submitted_at: 2025-03-09T13:22:31Z

Review comments:
diff_hunk: @@ -1243,12 +1257,13 @@ subroutine readPDOSRegions(children, geo, iAtInregion, regionLabels)
 
   end subroutine readPDOSRegions
 
-  !!* Read Tunneling and Dos options from analysis block
-  !!* tundos is the container to be filled
-  !!* ncont is needed for contact option allocation
+
+  !> Read Tunneling and Dos options from analysis block
   subroutine readTunAndDos(root, geo, tundos, transpar, temperature)
     type(fnode), pointer :: root
     type(TGeometry), intent(in) :: geo
+
+    !> the container to be filled
path: app/phonons/initphonons.F90
user: login: jubich
body: **T**he
created_at: 2025-03-09T12:58:09Z
author_association: MEMBER
diff_hunk: @@ -1573,6 +1594,7 @@ function getPL(iAt) result(PL)
 
   end function getPL
 
+
   !> select family of modes to analyze and restrict transmission
path: app/phonons/initphonons.F90
user: login: jubich
body: **S**elect
created_at: 2025-03-09T12:58:41Z
author_association: MEMBER
diff_hunk: @@ -1627,7 +1650,8 @@ subroutine checkTypeOfModes(root, tp)
 
   end subroutine checkTypeOfModes
 
-  ! check that transport direction is along z
+
+  !> check that transport direction is along z
path: app/phonons/initphonons.F90
user: login: jubich
body: **C**heck
created_at: 2025-03-09T13:00:24Z
author_association: MEMBER
diff_hunk: @@ -738,26 +738,25 @@ subroutine add_partial_results(pMat, matTot, matSKRes, iK, nK)
 
           matSKRes(:,:,:) = 0.0_dp
         endif
-#:if WITH_MPI
+      #:if WITH_MPI
         matSKRes(:,:,iK) = tmpMat
-#:else
+      #:else
         matSKRes(:,:,iK) = pMat
-#:endif
+      #:endif
       end if
 
-#:if WITH_MPI
+    #:if WITH_MPI
       deallocate(tmpMat)
-#:endif
+    #:endif
 
     end if
 
   end subroutine add_partial_results
 
 
 
-  !----------------------------------------------------------------------------
-
 #:if WITH_MPI
+
   !> utility to sum up partial results over K communicator
path: app/phonons/libnegfint.F90
user: login: jubich
body: **U**tility
created_at: 2025-03-09T13:07:13Z
author_association: MEMBER
diff_hunk: @@ -670,7 +670,7 @@ subroutine printH(fu, H)
 
   end subroutine printH
 
-  !----------------------------------------------------------------------------
+
   !> utility to allocate and sum partial results from different channels
path: app/phonons/libnegfint.F90
user: login: jubich
body: **U**tility
created_at: 2025-03-09T13:07:29Z
author_association: MEMBER
diff_hunk: @@ -1126,7 +1137,8 @@ subroutine readCp2kHessian(child)
 
   end subroutine readCp2kHessian
 
-  ! Subroutine removing entries in the Dynamical Matrix.
+
+  !> Subroutine removing entries in the Dynamical Matrix.
   ! Not used because identified as a wrong way
path: app/phonons/initphonons.F90
user: login: jubich
body: Shouldn't it be `!! Not...`? If not we might also ask whether lines 1486 and 1638 might also only require one `!`.
created_at: 2025-03-09T13:14:14Z
author_association: MEMBER
diff_hunk: @@ -126,7 +124,6 @@ subroutine negf_init(env, transpar, tundos, initinfo)
       ncont = 0
     endif
 
-    ! ------------------------------------------------------------------------------
     !! Set defaults and fill up the parameter structure with them
path: app/phonons/libnegfint.F90
user: login: jubich
body: Shouldn't this only use one `!`? And why not also delete the `! ---` lines in 277 and 291? 
created_at: 2025-03-09T13:15:41Z
author_association: MEMBER
diff_hunk: @@ -1083,8 +1094,8 @@ subroutine readCp2kHessian(child)
       call detailedError(child,"Hessian file "//trim(char(filename))//" does not exist")
     end if
 
-    !The derivatives matrix must be stored as the following order:
-
+    ! The derivatives matrix must be stored as the following order:
+    !
     ! For the x y z directions of atoms 1..n
     !   d^2 E        d^2 E       d^2 E       d^2 E        d^2 E
     ! ---------- + --------- + --------- + ---------- + ---------- +...
path: app/phonons/initphonons.F90
user: login: jubich
body: Shouldn't this also use `!!` instead of `!` similar to the above mentioned store order?
created_at: 2025-03-09T13:20:14Z
author_association: MEMBER

PR comments:
user: login: bhourahine
created_at: 2025-03-12T09:44:40Z
body: @jubich Thanks for looking at it. I've made your suggested changes and capitalized _all_ of the comment blocks.
author_association: MEMBER
user: login: jubich
created_at: 2025-03-15T10:54:17Z
body: @bhourahine Thanks for implementing the changes and sorry for the capitalization. I didn't expect there to be so many...
author_association: MEMBER