!
! This file is AUTOGENERATED
! To update, edit m_wcml_geometry.m4 and regenerate

module m_wcml_geometry

  use fox_m_fsys_realtypes, only: sp, dp
  use FoX_wxml, only: xmlf_t
#ifndef DUMMYLIB
  use FoX_wxml, only: xml_NewElement, xml_EndElement
  use FoX_wxml, only: xml_AddAttribute, xml_AddCharacters

! Fix for pgi, requires this explicitly:
  use m_wxml_overloads
#endif

  implicit none
  private

  interface cmlAddLength
    module procedure cmlAddLength_SP, cmlAddLength_DP
  end interface

  interface cmlAddAngle
    module procedure cmlAddAngle_SP, cmlAddAngle_DP
  end interface

  interface cmlAddTorsion
    module procedure cmlAddTorsion_SP, cmlAddTorsion_DP
  end interface

  public :: cmlAddLength
  public :: cmlAddAngle
  public :: cmlAddTorsion

contains

  subroutine cmlAddLength_sp(xf, id, atomRef1, atomRef2, length, fmt)
    type(xmlf_t), intent(inout) :: xf
    character(len=*), intent(in) :: id
    character(len=*), intent(in) :: atomRef1
    character(len=*), intent(in) :: atomRef2
    real(kind=sp), intent(in)    :: length
    character(len=*), intent(in), optional :: fmt

#ifndef DUMMYLIB
    call xml_NewElement(xf, "length")
    call xml_AddAttribute(xf, "id", trim(id))
    call xml_AddAttribute(xf, "atomRefs2", trim(atomRef1)//" "//trim(atomRef2))
    call xml_AddCharacters(xf, length, fmt)
    call xml_EndElement(xf, "length")
#endif

  end subroutine cmlAddLength_sp

  subroutine cmlAddAngle_sp(xf, id, atomRef1, atomRef2, atomRef3, angle, fmt)
    type(xmlf_t), intent(inout) :: xf
    character(len=*), intent(in) :: id
    character(len=*), intent(in) :: atomRef1
    character(len=*), intent(in) :: atomRef2
    character(len=*), intent(in) :: atomRef3
    real(kind=sp), intent(in)     :: angle
    character(len=*), intent(in), optional :: fmt

#ifndef DUMMYLIB
    call xml_NewElement(xf, "angle")
    call xml_AddAttribute(xf, "id", trim(id))
    call xml_AddAttribute(xf, "atomRefs3", trim(atomRef1)//" "//trim(atomRef2)//" "//trim(atomRef3))
    call xml_AddCharacters(xf, angle, fmt)
    call xml_EndElement(xf, "angle")
#endif

  end subroutine cmlAddAngle_sp

  subroutine cmlAddTorsion_sp(xf, id, atomRef1, atomRef2, atomRef3, atomRef4, torsion, fmt)
    type(xmlf_t), intent(inout) :: xf
    character(len=*), intent(in) :: id
    character(len=*), intent(in) :: atomRef1
    character(len=*), intent(in) :: atomRef2
    character(len=*), intent(in) :: atomRef3        ! ref to third atom
    character(len=*), intent(in) :: atomRef4
    real(kind=sp), intent(in)    :: torsion
    character(len=*), intent(in), optional :: fmt

#ifndef DUMMYLIB
    call xml_NewElement(xf, "torsion")
    call xml_AddAttribute(xf, "id", trim(id))
    call xml_AddAttribute(xf, "atomRefs4", &
         trim(atomRef1)//" "//trim(atomRef2)//" "//trim(atomRef3)//" "//trim(atomRef4))
    call xml_AddCharacters(xf, torsion, fmt)
    call xml_EndElement(xf, "torsion")
#endif

  end subroutine cmlAddTorsion_sp


  subroutine cmlAddLength_dp(xf, id, atomRef1, atomRef2, length, fmt)
    type(xmlf_t), intent(inout) :: xf
    character(len=*), intent(in) :: id
    character(len=*), intent(in) :: atomRef1
    character(len=*), intent(in) :: atomRef2
    real(kind=dp), intent(in)    :: length
    character(len=*), intent(in), optional :: fmt

#ifndef DUMMYLIB
    call xml_NewElement(xf, "length")
    call xml_AddAttribute(xf, "id", trim(id))
    call xml_AddAttribute(xf, "atomRefs2", trim(atomRef1)//" "//trim(atomRef2))
    call xml_AddCharacters(xf, length, fmt)
    call xml_EndElement(xf, "length")
#endif

  end subroutine cmlAddLength_dp

  subroutine cmlAddAngle_dp(xf, id, atomRef1, atomRef2, atomRef3, angle, fmt)
    type(xmlf_t), intent(inout) :: xf
    character(len=*), intent(in) :: id
    character(len=*), intent(in) :: atomRef1
    character(len=*), intent(in) :: atomRef2
    character(len=*), intent(in) :: atomRef3
    real(kind=dp), intent(in)     :: angle
    character(len=*), intent(in), optional :: fmt

#ifndef DUMMYLIB
    call xml_NewElement(xf, "angle")
    call xml_AddAttribute(xf, "id", trim(id))
    call xml_AddAttribute(xf, "atomRefs3", trim(atomRef1)//" "//trim(atomRef2)//" "//trim(atomRef3))
    call xml_AddCharacters(xf, angle, fmt)
    call xml_EndElement(xf, "angle")
#endif

  end subroutine cmlAddAngle_dp

  subroutine cmlAddTorsion_dp(xf, id, atomRef1, atomRef2, atomRef3, atomRef4, torsion, fmt)
    type(xmlf_t), intent(inout) :: xf
    character(len=*), intent(in) :: id
    character(len=*), intent(in) :: atomRef1
    character(len=*), intent(in) :: atomRef2
    character(len=*), intent(in) :: atomRef3        ! ref to third atom
    character(len=*), intent(in) :: atomRef4
    real(kind=dp), intent(in)    :: torsion
    character(len=*), intent(in), optional :: fmt

#ifndef DUMMYLIB
    call xml_NewElement(xf, "torsion")
    call xml_AddAttribute(xf, "id", trim(id))
    call xml_AddAttribute(xf, "atomRefs4", &
         trim(atomRef1)//" "//trim(atomRef2)//" "//trim(atomRef3)//" "//trim(atomRef4))
    call xml_AddCharacters(xf, torsion, fmt)
    call xml_EndElement(xf, "torsion")
#endif

  end subroutine cmlAddTorsion_dp


end module m_wcml_geometry
