LCOV - code coverage report
Current view: top level - src/subsys - molecule_kind_types.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:936074a) Lines: 91.3 % 393 359
Test Date: 2025-12-04 06:27:48 Functions: 42.9 % 28 12

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2025 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief Define the molecule kind structure types and the corresponding
      10              : !>      functionality
      11              : !> \par History
      12              : !>      Teodoro Laino [tlaino] 12.2008 - Preparing for VIRTUAL SITE constraints
      13              : !>                                       (patch by Marcel Baer)
      14              : !> \author Matthias Krack (22.08.2003)
      15              : ! **************************************************************************************************
      16              : MODULE molecule_kind_types
      17              :    USE atomic_kind_types,               ONLY: atomic_kind_type,&
      18              :                                               get_atomic_kind
      19              :    USE cell_types,                      ONLY: periodicity_string,&
      20              :                                               use_perd_x,&
      21              :                                               use_perd_xy,&
      22              :                                               use_perd_xyz,&
      23              :                                               use_perd_xz,&
      24              :                                               use_perd_y,&
      25              :                                               use_perd_yz,&
      26              :                                               use_perd_z
      27              :    USE colvar_types,                    ONLY: &
      28              :         Wc_colvar_id, acid_hyd_dist_colvar_id, acid_hyd_shell_colvar_id, angle_colvar_id, &
      29              :         colvar_counters, combine_colvar_id, coord_colvar_id, dfunct_colvar_id, dist_colvar_id, &
      30              :         distance_from_path_colvar_id, gyration_colvar_id, hbp_colvar_id, hydronium_dist_colvar_id, &
      31              :         hydronium_shell_colvar_id, mindist_colvar_id, no_colvar_id, plane_distance_colvar_id, &
      32              :         plane_plane_angle_colvar_id, population_colvar_id, qparm_colvar_id, &
      33              :         reaction_path_colvar_id, ring_puckering_colvar_id, rmsd_colvar_id, rotation_colvar_id, &
      34              :         torsion_colvar_id, u_colvar_id, xyz_diag_colvar_id, xyz_outerdiag_colvar_id
      35              :    USE cp_log_handling,                 ONLY: cp_get_default_logger,&
      36              :                                               cp_logger_type
      37              :    USE cp_output_handling,              ONLY: cp_print_key_finished_output,&
      38              :                                               cp_print_key_unit_nr
      39              :    USE cp_units,                        ONLY: cp_unit_from_cp2k
      40              :    USE force_field_kind_types,          ONLY: &
      41              :         bend_kind_type, bond_kind_type, do_ff_undef, impr_kind_dealloc_ref, impr_kind_type, &
      42              :         opbend_kind_type, torsion_kind_dealloc_ref, torsion_kind_type, ub_kind_dealloc_ref, &
      43              :         ub_kind_type
      44              :    USE input_section_types,             ONLY: section_vals_type
      45              :    USE kinds,                           ONLY: default_string_length,&
      46              :                                               dp
      47              :    USE shell_potential_types,           ONLY: shell_kind_type
      48              : #include "../base/base_uses.f90"
      49              : 
      50              :    IMPLICIT NONE
      51              : 
      52              :    PRIVATE
      53              : 
      54              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'molecule_kind_types'
      55              : 
      56              :    ! Define the derived structure types
      57              : 
      58              :    TYPE atom_type
      59              :       TYPE(atomic_kind_type), POINTER :: atomic_kind => NULL()
      60              :       INTEGER :: id_name = 0
      61              :    END TYPE atom_type
      62              : 
      63              :    TYPE shell_type
      64              :       INTEGER :: a = 0
      65              :       CHARACTER(LEN=default_string_length) :: name = ""
      66              :       TYPE(shell_kind_type), POINTER :: shell_kind => NULL()
      67              :    END TYPE shell_type
      68              : 
      69              :    TYPE bond_type
      70              :       INTEGER :: a = 0, b = 0
      71              :       INTEGER :: id_type = do_ff_undef, itype = 0
      72              :       TYPE(bond_kind_type), POINTER :: bond_kind => NULL()
      73              :    END TYPE bond_type
      74              : 
      75              :    TYPE bend_type
      76              :       INTEGER :: a = 0, b = 0, c = 0
      77              :       INTEGER :: id_type = do_ff_undef, itype = 0
      78              :       TYPE(bend_kind_type), POINTER :: bend_kind => NULL()
      79              :    END TYPE bend_type
      80              : 
      81              :    TYPE ub_type
      82              :       INTEGER :: a = 0, b = 0, c = 0
      83              :       INTEGER :: id_type = do_ff_undef, itype = 0
      84              :       TYPE(ub_kind_type), POINTER :: ub_kind => NULL()
      85              :    END TYPE ub_type
      86              : 
      87              :    TYPE torsion_type
      88              :       INTEGER :: a = 0, b = 0, c = 0, d = 0
      89              :       INTEGER :: id_type = do_ff_undef, itype = 0
      90              :       TYPE(torsion_kind_type), POINTER :: torsion_kind => NULL()
      91              :    END TYPE torsion_type
      92              : 
      93              :    TYPE impr_type
      94              :       INTEGER :: a = 0, b = 0, c = 0, d = 0
      95              :       INTEGER :: id_type = do_ff_undef, itype = 0
      96              :       TYPE(impr_kind_type), POINTER :: impr_kind => NULL()
      97              :    END TYPE impr_type
      98              : 
      99              :    TYPE opbend_type
     100              :       INTEGER :: a = 0, b = 0, c = 0, d = 0
     101              :       INTEGER :: id_type = do_ff_undef, itype = 0
     102              :       TYPE(opbend_kind_type), POINTER :: opbend_kind => NULL()
     103              :    END TYPE opbend_type
     104              : 
     105              :    TYPE restraint_type
     106              :       LOGICAL :: active = .FALSE.
     107              :       REAL(KIND=dp) :: k0 = 0.0_dp
     108              :    END TYPE restraint_type
     109              : 
     110              :    ! Constraint types
     111              :    TYPE colvar_constraint_type
     112              :       INTEGER                        :: type_id = no_colvar_id
     113              :       INTEGER                        :: inp_seq_num = 0
     114              :       LOGICAL                        :: use_points = .FALSE.
     115              :       REAL(KIND=dp)                  :: expected_value = 0.0_dp
     116              :       REAL(KIND=dp)                  :: expected_value_growth_speed = 0.0_dp
     117              :       INTEGER, POINTER, DIMENSION(:) :: i_atoms => NULL()
     118              :       TYPE(restraint_type)           :: restraint = restraint_type()
     119              :    END TYPE colvar_constraint_type
     120              : 
     121              :    TYPE g3x3_constraint_type
     122              :       INTEGER                        :: a = 0, b = 0, c = 0
     123              :       REAL(KIND=dp)                  :: dab = 0.0_dp, dac = 0.0_dp, dbc = 0.0_dp
     124              :       TYPE(restraint_type)           :: restraint = restraint_type()
     125              :    END TYPE g3x3_constraint_type
     126              : 
     127              :    TYPE g4x6_constraint_type
     128              :       INTEGER                        :: a = 0, b = 0, c = 0, d = 0
     129              :       REAL(KIND=dp)                  :: dab = 0.0_dp, dac = 0.0_dp, dbc = 0.0_dp, &
     130              :                                         dad = 0.0_dp, dbd = 0.0_dp, dcd = 0.0_dp
     131              :       TYPE(restraint_type)           :: restraint = restraint_type()
     132              :    END TYPE g4x6_constraint_type
     133              : 
     134              :    TYPE vsite_constraint_type
     135              :       INTEGER                        :: a = 0, b = 0, c = 0, d = 0
     136              :       REAL(KIND=dp)                  :: wbc = 0.0_dp, wdc = 0.0_dp
     137              :       TYPE(restraint_type)           :: restraint = restraint_type()
     138              :    END TYPE vsite_constraint_type
     139              : 
     140              :    TYPE fixd_constraint_type
     141              :       TYPE(restraint_type)           :: restraint = restraint_type()
     142              :       INTEGER                        :: fixd = 0, itype = 0
     143              :       REAL(KIND=dp), DIMENSION(3)    :: coord = 0.0_dp
     144              :    END TYPE fixd_constraint_type
     145              : 
     146              :    TYPE local_fixd_constraint_type
     147              :       INTEGER                        :: ifixd_index = 0, ikind = 0
     148              :    END TYPE local_fixd_constraint_type
     149              : 
     150              :    ! Molecule kind type
     151              :    TYPE molecule_kind_type
     152              :       TYPE(atom_type), DIMENSION(:), POINTER             :: atom_list => NULL()
     153              :       TYPE(bond_kind_type), DIMENSION(:), POINTER        :: bond_kind_set => NULL()
     154              :       TYPE(bond_type), DIMENSION(:), POINTER             :: bond_list => NULL()
     155              :       TYPE(bend_kind_type), DIMENSION(:), POINTER        :: bend_kind_set => NULL()
     156              :       TYPE(bend_type), DIMENSION(:), POINTER             :: bend_list => NULL()
     157              :       TYPE(ub_kind_type), DIMENSION(:), POINTER          :: ub_kind_set => NULL()
     158              :       TYPE(ub_type), DIMENSION(:), POINTER               :: ub_list => NULL()
     159              :       TYPE(torsion_kind_type), DIMENSION(:), POINTER     :: torsion_kind_set => NULL()
     160              :       TYPE(torsion_type), DIMENSION(:), POINTER          :: torsion_list => NULL()
     161              :       TYPE(impr_kind_type), DIMENSION(:), POINTER        :: impr_kind_set => NULL()
     162              :       TYPE(impr_type), DIMENSION(:), POINTER             :: impr_list => NULL()
     163              :       TYPE(opbend_kind_type), DIMENSION(:), POINTER      :: opbend_kind_set => NULL()
     164              :       TYPE(opbend_type), DIMENSION(:), POINTER           :: opbend_list => NULL()
     165              :       TYPE(colvar_constraint_type), DIMENSION(:), &
     166              :          POINTER                                         :: colv_list => NULL()
     167              :       TYPE(g3x3_constraint_type), DIMENSION(:), POINTER  :: g3x3_list => NULL()
     168              :       TYPE(g4x6_constraint_type), DIMENSION(:), POINTER  :: g4x6_list => NULL()
     169              :       TYPE(vsite_constraint_type), DIMENSION(:), POINTER :: vsite_list => NULL()
     170              :       TYPE(fixd_constraint_type), DIMENSION(:), POINTER  :: fixd_list => NULL()
     171              :       TYPE(shell_type), DIMENSION(:), POINTER            :: shell_list => NULL()
     172              :       CHARACTER(LEN=default_string_length)               :: name = ""
     173              :       REAL(KIND=dp)                                      :: charge = 0.0_dp, &
     174              :                                                             mass = 0.0_dp
     175              :       INTEGER                                            :: kind_number = 0, &
     176              :                                                             natom = 0, &
     177              :                                                             nbond = 0, &
     178              :                                                             nbend = 0, &
     179              :                                                             nimpr = 0, &
     180              :                                                             nopbend = 0, &
     181              :                                                             ntorsion = 0, &
     182              :                                                             nub = 0, &
     183              :                                                             ng3x3 = 0, &
     184              :                                                             ng3x3_restraint = 0, &
     185              :                                                             ng4x6 = 0, &
     186              :                                                             ng4x6_restraint = 0, &
     187              :                                                             nvsite = 0, &
     188              :                                                             nvsite_restraint = 0, &
     189              :                                                             nfixd = 0, &
     190              :                                                             nfixd_restraint = 0, &
     191              :                                                             nmolecule = 0, &
     192              :                                                             nshell = 0
     193              :       TYPE(colvar_counters)                              :: ncolv = colvar_counters()
     194              :       INTEGER                                            :: nsgf = 0, &
     195              :                                                             nelectron = 0, &
     196              :                                                             nelectron_alpha = 0, &
     197              :                                                             nelectron_beta = 0
     198              :       INTEGER, DIMENSION(:), POINTER                     :: molecule_list => NULL()
     199              :       LOGICAL                                            :: molname_generated = .FALSE.
     200              :    END TYPE molecule_kind_type
     201              : 
     202              :    ! Public subroutines
     203              :    PUBLIC :: allocate_molecule_kind_set, &
     204              :              deallocate_molecule_kind_set, &
     205              :              get_molecule_kind, &
     206              :              get_molecule_kind_set, &
     207              :              set_molecule_kind, &
     208              :              write_molecule_kind_set, &
     209              :              setup_colvar_counters, &
     210              :              write_colvar_constraint, &
     211              :              write_fixd_constraint, &
     212              :              write_g3x3_constraint, &
     213              :              write_g4x6_constraint
     214              : 
     215              :    ! Public data types
     216              :    PUBLIC :: atom_type, &
     217              :              bend_type, &
     218              :              bond_type, &
     219              :              ub_type, &
     220              :              torsion_type, &
     221              :              impr_type, &
     222              :              opbend_type, &
     223              :              colvar_constraint_type, &
     224              :              g3x3_constraint_type, &
     225              :              g4x6_constraint_type, &
     226              :              vsite_constraint_type, &
     227              :              fixd_constraint_type, &
     228              :              local_fixd_constraint_type, &
     229              :              molecule_kind_type, &
     230              :              shell_type
     231              : 
     232              : CONTAINS
     233              : 
     234              : ! **************************************************************************************************
     235              : !> \brief ...
     236              : !> \param colv_list ...
     237              : !> \param ncolv ...
     238              : ! **************************************************************************************************
     239       146787 :    SUBROUTINE setup_colvar_counters(colv_list, ncolv)
     240              :       TYPE(colvar_constraint_type), DIMENSION(:), &
     241              :          POINTER                                         :: colv_list
     242              :       TYPE(colvar_counters), INTENT(OUT)                 :: ncolv
     243              : 
     244              :       INTEGER                                            :: k
     245              : 
     246       146787 :       IF (ASSOCIATED(colv_list)) THEN
     247         1070 :          DO k = 1, SIZE(colv_list)
     248          448 :             IF (colv_list(k)%restraint%active) ncolv%nrestraint = ncolv%nrestraint + 1
     249          622 :             SELECT CASE (colv_list(k)%type_id)
     250              :             CASE (angle_colvar_id)
     251           50 :                ncolv%nangle = ncolv%nangle + 1
     252              :             CASE (coord_colvar_id)
     253            2 :                ncolv%ncoord = ncolv%ncoord + 1
     254              :             CASE (population_colvar_id)
     255            0 :                ncolv%npopulation = ncolv%npopulation + 1
     256              :             CASE (gyration_colvar_id)
     257            0 :                ncolv%ngyration = ncolv%ngyration + 1
     258              :             CASE (rotation_colvar_id)
     259            0 :                ncolv%nrot = ncolv%nrot + 1
     260              :             CASE (dist_colvar_id)
     261          334 :                ncolv%ndist = ncolv%ndist + 1
     262              :             CASE (dfunct_colvar_id)
     263            4 :                ncolv%ndfunct = ncolv%ndfunct + 1
     264              :             CASE (plane_distance_colvar_id)
     265            0 :                ncolv%nplane_dist = ncolv%nplane_dist + 1
     266              :             CASE (plane_plane_angle_colvar_id)
     267            4 :                ncolv%nplane_angle = ncolv%nplane_angle + 1
     268              :             CASE (torsion_colvar_id)
     269           38 :                ncolv%ntorsion = ncolv%ntorsion + 1
     270              :             CASE (qparm_colvar_id)
     271            0 :                ncolv%nqparm = ncolv%nqparm + 1
     272              :             CASE (xyz_diag_colvar_id)
     273            6 :                ncolv%nxyz_diag = ncolv%nxyz_diag + 1
     274              :             CASE (xyz_outerdiag_colvar_id)
     275            6 :                ncolv%nxyz_outerdiag = ncolv%nxyz_outerdiag + 1
     276              :             CASE (hydronium_shell_colvar_id)
     277            0 :                ncolv%nhydronium_shell = ncolv%nhydronium_shell + 1
     278              :             CASE (hydronium_dist_colvar_id)
     279            0 :                ncolv%nhydronium_dist = ncolv%nhydronium_dist + 1
     280              :             CASE (acid_hyd_dist_colvar_id)
     281            0 :                ncolv%nacid_hyd_dist = ncolv%nacid_hyd_dist + 1
     282              :             CASE (acid_hyd_shell_colvar_id)
     283            0 :                ncolv%nacid_hyd_shell = ncolv%nacid_hyd_shell + 1
     284              :             CASE (reaction_path_colvar_id)
     285            2 :                ncolv%nreactionpath = ncolv%nreactionpath + 1
     286              :             CASE (combine_colvar_id)
     287            2 :                ncolv%ncombinecvs = ncolv%ncombinecvs + 1
     288              :             CASE DEFAULT
     289          448 :                CPABORT("")
     290              :             END SELECT
     291              :          END DO
     292              :       END IF
     293              :       ncolv%ntot = ncolv%ndist + &
     294              :                    ncolv%nangle + &
     295              :                    ncolv%ntorsion + &
     296              :                    ncolv%ncoord + &
     297              :                    ncolv%nplane_dist + &
     298              :                    ncolv%nplane_angle + &
     299              :                    ncolv%ndfunct + &
     300              :                    ncolv%nrot + &
     301              :                    ncolv%nqparm + &
     302              :                    ncolv%nxyz_diag + &
     303              :                    ncolv%nxyz_outerdiag + &
     304              :                    ncolv%nhydronium_shell + &
     305              :                    ncolv%nhydronium_dist + &
     306              :                    ncolv%nacid_hyd_dist + &
     307              :                    ncolv%nacid_hyd_shell + &
     308              :                    ncolv%nreactionpath + &
     309              :                    ncolv%ncombinecvs + &
     310              :                    ncolv%npopulation + &
     311       146787 :                    ncolv%ngyration
     312              : 
     313       146787 :    END SUBROUTINE setup_colvar_counters
     314              : 
     315              : ! **************************************************************************************************
     316              : !> \brief   Allocate and initialize a molecule kind set.
     317              : !> \param molecule_kind_set ...
     318              : !> \param nmolecule_kind ...
     319              : !> \date    22.08.2003
     320              : !> \author  Matthias Krack
     321              : !> \version 1.0
     322              : ! **************************************************************************************************
     323        10274 :    SUBROUTINE allocate_molecule_kind_set(molecule_kind_set, nmolecule_kind)
     324              :       TYPE(molecule_kind_type), DIMENSION(:), POINTER    :: molecule_kind_set
     325              :       INTEGER, INTENT(IN)                                :: nmolecule_kind
     326              : 
     327              :       INTEGER                                            :: imolecule_kind
     328              : 
     329        10274 :       IF (ASSOCIATED(molecule_kind_set)) THEN
     330            0 :          CALL deallocate_molecule_kind_set(molecule_kind_set)
     331              :       END IF
     332              : 
     333       167251 :       ALLOCATE (molecule_kind_set(nmolecule_kind))
     334              : 
     335       146703 :       DO imolecule_kind = 1, nmolecule_kind
     336       136429 :          molecule_kind_set(imolecule_kind)%kind_number = imolecule_kind
     337              :          CALL setup_colvar_counters(molecule_kind_set(imolecule_kind)%colv_list, &
     338       146703 :                                     molecule_kind_set(imolecule_kind)%ncolv)
     339              :       END DO
     340              : 
     341        10274 :    END SUBROUTINE allocate_molecule_kind_set
     342              : 
     343              : ! **************************************************************************************************
     344              : !> \brief   Deallocate a molecule kind set.
     345              : !> \param molecule_kind_set ...
     346              : !> \date    22.08.2003
     347              : !> \author  Matthias Krack
     348              : !> \version 1.0
     349              : ! **************************************************************************************************
     350        10274 :    SUBROUTINE deallocate_molecule_kind_set(molecule_kind_set)
     351              : 
     352              :       TYPE(molecule_kind_type), DIMENSION(:), POINTER    :: molecule_kind_set
     353              : 
     354              :       INTEGER                                            :: i, imolecule_kind, j, nmolecule_kind
     355              : 
     356        10274 :       IF (ASSOCIATED(molecule_kind_set)) THEN
     357              : 
     358        10274 :          nmolecule_kind = SIZE(molecule_kind_set)
     359              : 
     360       146703 :          DO imolecule_kind = 1, nmolecule_kind
     361              : 
     362       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%atom_list)) THEN
     363       136429 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%atom_list)
     364              :             END IF
     365       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%bend_kind_set)) THEN
     366       122739 :                DO i = 1, SIZE(molecule_kind_set(imolecule_kind)%bend_kind_set)
     367        93640 :                   IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%bend_kind_set(i)%legendre%coeffs)) &
     368        31166 :                      DEALLOCATE (molecule_kind_set(imolecule_kind)%bend_kind_set(i)%legendre%coeffs)
     369              :                END DO
     370        29099 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%bend_kind_set)
     371              :             END IF
     372       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%bend_list)) THEN
     373       136429 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%bend_list)
     374              :             END IF
     375       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%ub_list)) THEN
     376       136429 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%ub_list)
     377              :             END IF
     378       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%ub_kind_set)) THEN
     379        29085 :                CALL ub_kind_dealloc_ref(molecule_kind_set(imolecule_kind)%ub_kind_set)
     380              :             END IF
     381       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%impr_list)) THEN
     382       136429 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%impr_list)
     383              :             END IF
     384       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%impr_kind_set)) THEN
     385         4882 :                DO i = 1, SIZE(molecule_kind_set(imolecule_kind)%impr_kind_set)
     386         4882 :                   CALL impr_kind_dealloc_ref() !This Subroutine doesn't deallocate anything, maybe needs to be implemented
     387              :                END DO
     388         1672 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%impr_kind_set)
     389              :             END IF
     390       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%opbend_list)) THEN
     391       136429 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%opbend_list)
     392              :             END IF
     393       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%opbend_kind_set)) THEN
     394         1672 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%opbend_kind_set)
     395              :             END IF
     396       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%bond_kind_set)) THEN
     397        29429 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%bond_kind_set)
     398              :             END IF
     399       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%bond_list)) THEN
     400       136429 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%bond_list)
     401              :             END IF
     402       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%colv_list)) THEN
     403          960 :                DO j = 1, SIZE(molecule_kind_set(imolecule_kind)%colv_list)
     404          960 :                   DEALLOCATE (molecule_kind_set(imolecule_kind)%colv_list(j)%i_atoms)
     405              :                END DO
     406          578 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%colv_list)
     407              :             END IF
     408       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%g3x3_list)) THEN
     409          270 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%g3x3_list)
     410              :             END IF
     411       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%g4x6_list)) THEN
     412           20 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%g4x6_list)
     413              :             END IF
     414       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%vsite_list)) THEN
     415           10 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%vsite_list)
     416              :             END IF
     417       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%fixd_list)) THEN
     418         4926 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%fixd_list)
     419              :             END IF
     420       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%torsion_kind_set)) THEN
     421        83961 :                DO i = 1, SIZE(molecule_kind_set(imolecule_kind)%torsion_kind_set)
     422        83961 :                   CALL torsion_kind_dealloc_ref(molecule_kind_set(imolecule_kind)%torsion_kind_set(i))
     423              :                END DO
     424         5532 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%torsion_kind_set)
     425              :             END IF
     426       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%shell_list)) THEN
     427        10874 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%shell_list)
     428              :             END IF
     429       136429 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%torsion_list)) THEN
     430       136429 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%torsion_list)
     431              :             END IF
     432       146703 :             IF (ASSOCIATED(molecule_kind_set(imolecule_kind)%molecule_list)) THEN
     433       136429 :                DEALLOCATE (molecule_kind_set(imolecule_kind)%molecule_list)
     434              :             END IF
     435              :          END DO
     436              : 
     437        10274 :          DEALLOCATE (molecule_kind_set)
     438              :       END IF
     439        10274 :       NULLIFY (molecule_kind_set)
     440              : 
     441        10274 :    END SUBROUTINE deallocate_molecule_kind_set
     442              : 
     443              : ! **************************************************************************************************
     444              : !> \brief   Get informations about a molecule kind.
     445              : !> \param molecule_kind ...
     446              : !> \param atom_list ...
     447              : !> \param bond_list ...
     448              : !> \param bend_list ...
     449              : !> \param ub_list ...
     450              : !> \param impr_list ...
     451              : !> \param opbend_list ...
     452              : !> \param colv_list ...
     453              : !> \param fixd_list ...
     454              : !> \param g3x3_list ...
     455              : !> \param g4x6_list ...
     456              : !> \param vsite_list ...
     457              : !> \param torsion_list ...
     458              : !> \param shell_list ...
     459              : !> \param name ...
     460              : !> \param mass ...
     461              : !> \param charge ...
     462              : !> \param kind_number ...
     463              : !> \param natom ...
     464              : !> \param nbend ...
     465              : !> \param nbond ...
     466              : !> \param nub ...
     467              : !> \param nimpr ...
     468              : !> \param nopbend ...
     469              : !> \param nconstraint ...
     470              : !> \param nconstraint_fixd ...
     471              : !> \param nfixd ...
     472              : !> \param ncolv ...
     473              : !> \param ng3x3 ...
     474              : !> \param ng4x6 ...
     475              : !> \param nvsite ...
     476              : !> \param nfixd_restraint ...
     477              : !> \param ng3x3_restraint ...
     478              : !> \param ng4x6_restraint ...
     479              : !> \param nvsite_restraint ...
     480              : !> \param nrestraints ...
     481              : !> \param nmolecule ...
     482              : !> \param nsgf ...
     483              : !> \param nshell ...
     484              : !> \param ntorsion ...
     485              : !> \param molecule_list ...
     486              : !> \param nelectron ...
     487              : !> \param nelectron_alpha ...
     488              : !> \param nelectron_beta ...
     489              : !> \param bond_kind_set ...
     490              : !> \param bend_kind_set ...
     491              : !> \param ub_kind_set ...
     492              : !> \param impr_kind_set ...
     493              : !> \param opbend_kind_set ...
     494              : !> \param torsion_kind_set ...
     495              : !> \param molname_generated ...
     496              : !> \date    27.08.2003
     497              : !> \author  Matthias Krack
     498              : !> \version 1.0
     499              : ! **************************************************************************************************
     500     16468556 :    SUBROUTINE get_molecule_kind(molecule_kind, atom_list, bond_list, bend_list, &
     501              :                                 ub_list, impr_list, opbend_list, colv_list, fixd_list, &
     502              :                                 g3x3_list, g4x6_list, vsite_list, torsion_list, shell_list, &
     503              :                                 name, mass, charge, kind_number, natom, nbend, nbond, nub, &
     504              :                                 nimpr, nopbend, nconstraint, nconstraint_fixd, nfixd, ncolv, ng3x3, ng4x6, &
     505              :                                 nvsite, nfixd_restraint, ng3x3_restraint, ng4x6_restraint, &
     506              :                                 nvsite_restraint, nrestraints, nmolecule, nsgf, nshell, ntorsion, &
     507              :                                 molecule_list, nelectron, nelectron_alpha, nelectron_beta, &
     508              :                                 bond_kind_set, bend_kind_set, &
     509              :                                 ub_kind_set, impr_kind_set, opbend_kind_set, torsion_kind_set, &
     510              :                                 molname_generated)
     511              : 
     512              :       TYPE(molecule_kind_type), INTENT(IN)               :: molecule_kind
     513              :       TYPE(atom_type), DIMENSION(:), OPTIONAL, POINTER   :: atom_list
     514              :       TYPE(bond_type), DIMENSION(:), OPTIONAL, POINTER   :: bond_list
     515              :       TYPE(bend_type), DIMENSION(:), OPTIONAL, POINTER   :: bend_list
     516              :       TYPE(ub_type), DIMENSION(:), OPTIONAL, POINTER     :: ub_list
     517              :       TYPE(impr_type), DIMENSION(:), OPTIONAL, POINTER   :: impr_list
     518              :       TYPE(opbend_type), DIMENSION(:), OPTIONAL, POINTER :: opbend_list
     519              :       TYPE(colvar_constraint_type), DIMENSION(:), &
     520              :          OPTIONAL, POINTER                               :: colv_list
     521              :       TYPE(fixd_constraint_type), DIMENSION(:), &
     522              :          OPTIONAL, POINTER                               :: fixd_list
     523              :       TYPE(g3x3_constraint_type), DIMENSION(:), &
     524              :          OPTIONAL, POINTER                               :: g3x3_list
     525              :       TYPE(g4x6_constraint_type), DIMENSION(:), &
     526              :          OPTIONAL, POINTER                               :: g4x6_list
     527              :       TYPE(vsite_constraint_type), DIMENSION(:), &
     528              :          OPTIONAL, POINTER                               :: vsite_list
     529              :       TYPE(torsion_type), DIMENSION(:), OPTIONAL, &
     530              :          POINTER                                         :: torsion_list
     531              :       TYPE(shell_type), DIMENSION(:), OPTIONAL, POINTER  :: shell_list
     532              :       CHARACTER(LEN=default_string_length), &
     533              :          INTENT(OUT), OPTIONAL                           :: name
     534              :       REAL(KIND=dp), OPTIONAL                            :: mass, charge
     535              :       INTEGER, INTENT(OUT), OPTIONAL                     :: kind_number, natom, nbend, nbond, nub, &
     536              :                                                             nimpr, nopbend, nconstraint, &
     537              :                                                             nconstraint_fixd, nfixd
     538              :       TYPE(colvar_counters), INTENT(out), OPTIONAL       :: ncolv
     539              :       INTEGER, INTENT(OUT), OPTIONAL :: ng3x3, ng4x6, nvsite, nfixd_restraint, ng3x3_restraint, &
     540              :          ng4x6_restraint, nvsite_restraint, nrestraints, nmolecule, nsgf, nshell, ntorsion
     541              :       INTEGER, DIMENSION(:), OPTIONAL, POINTER           :: molecule_list
     542              :       INTEGER, INTENT(OUT), OPTIONAL                     :: nelectron, nelectron_alpha, &
     543              :                                                             nelectron_beta
     544              :       TYPE(bond_kind_type), DIMENSION(:), OPTIONAL, &
     545              :          POINTER                                         :: bond_kind_set
     546              :       TYPE(bend_kind_type), DIMENSION(:), OPTIONAL, &
     547              :          POINTER                                         :: bend_kind_set
     548              :       TYPE(ub_kind_type), DIMENSION(:), OPTIONAL, &
     549              :          POINTER                                         :: ub_kind_set
     550              :       TYPE(impr_kind_type), DIMENSION(:), OPTIONAL, &
     551              :          POINTER                                         :: impr_kind_set
     552              :       TYPE(opbend_kind_type), DIMENSION(:), OPTIONAL, &
     553              :          POINTER                                         :: opbend_kind_set
     554              :       TYPE(torsion_kind_type), DIMENSION(:), OPTIONAL, &
     555              :          POINTER                                         :: torsion_kind_set
     556              :       LOGICAL, INTENT(OUT), OPTIONAL                     :: molname_generated
     557              : 
     558              :       INTEGER                                            :: i
     559              : 
     560     16468556 :       IF (PRESENT(atom_list)) atom_list => molecule_kind%atom_list
     561     16468556 :       IF (PRESENT(bend_list)) bend_list => molecule_kind%bend_list
     562     16468556 :       IF (PRESENT(bond_list)) bond_list => molecule_kind%bond_list
     563     16468556 :       IF (PRESENT(impr_list)) impr_list => molecule_kind%impr_list
     564     16468556 :       IF (PRESENT(opbend_list)) opbend_list => molecule_kind%opbend_list
     565     16468556 :       IF (PRESENT(ub_list)) ub_list => molecule_kind%ub_list
     566     16468556 :       IF (PRESENT(bond_kind_set)) bond_kind_set => molecule_kind%bond_kind_set
     567     16468556 :       IF (PRESENT(bend_kind_set)) bend_kind_set => molecule_kind%bend_kind_set
     568     16468556 :       IF (PRESENT(ub_kind_set)) ub_kind_set => molecule_kind%ub_kind_set
     569     16468556 :       IF (PRESENT(impr_kind_set)) impr_kind_set => molecule_kind%impr_kind_set
     570     16468556 :       IF (PRESENT(opbend_kind_set)) opbend_kind_set => molecule_kind%opbend_kind_set
     571     16468556 :       IF (PRESENT(torsion_kind_set)) torsion_kind_set => molecule_kind%torsion_kind_set
     572     16468556 :       IF (PRESENT(colv_list)) colv_list => molecule_kind%colv_list
     573     16468556 :       IF (PRESENT(g3x3_list)) g3x3_list => molecule_kind%g3x3_list
     574     16468556 :       IF (PRESENT(g4x6_list)) g4x6_list => molecule_kind%g4x6_list
     575     16468556 :       IF (PRESENT(vsite_list)) vsite_list => molecule_kind%vsite_list
     576     16468556 :       IF (PRESENT(fixd_list)) fixd_list => molecule_kind%fixd_list
     577     16468556 :       IF (PRESENT(torsion_list)) torsion_list => molecule_kind%torsion_list
     578     16468556 :       IF (PRESENT(shell_list)) shell_list => molecule_kind%shell_list
     579     16468556 :       IF (PRESENT(name)) name = molecule_kind%name
     580     16468556 :       IF (PRESENT(molname_generated)) molname_generated = molecule_kind%molname_generated
     581     16468556 :       IF (PRESENT(mass)) mass = molecule_kind%mass
     582     16468556 :       IF (PRESENT(charge)) charge = molecule_kind%charge
     583     16468556 :       IF (PRESENT(kind_number)) kind_number = molecule_kind%kind_number
     584     16468556 :       IF (PRESENT(natom)) natom = molecule_kind%natom
     585     16468556 :       IF (PRESENT(nbend)) nbend = molecule_kind%nbend
     586     16468556 :       IF (PRESENT(nbond)) nbond = molecule_kind%nbond
     587     16468556 :       IF (PRESENT(nub)) nub = molecule_kind%nub
     588     16468556 :       IF (PRESENT(nimpr)) nimpr = molecule_kind%nimpr
     589     16468556 :       IF (PRESENT(nopbend)) nopbend = molecule_kind%nopbend
     590     16468556 :       IF (PRESENT(nconstraint)) nconstraint = (molecule_kind%ncolv%ntot - molecule_kind%ncolv%nrestraint) + &
     591              :                                               3*(molecule_kind%ng3x3 - molecule_kind%ng3x3_restraint) + &
     592              :                                               6*(molecule_kind%ng4x6 - molecule_kind%ng4x6_restraint) + &
     593      3180952 :                                               3*(molecule_kind%nvsite - molecule_kind%nvsite_restraint)
     594     16468556 :       IF (PRESENT(ncolv)) ncolv = molecule_kind%ncolv
     595     16468556 :       IF (PRESENT(ng3x3)) ng3x3 = molecule_kind%ng3x3
     596     16468556 :       IF (PRESENT(ng4x6)) ng4x6 = molecule_kind%ng4x6
     597     16468556 :       IF (PRESENT(nvsite)) nvsite = molecule_kind%nvsite
     598              :       ! Number of atoms that have one or more components fixed
     599     16468556 :       IF (PRESENT(nfixd)) nfixd = molecule_kind%nfixd
     600              :       ! Number of degrees of freedom fixed
     601     16468556 :       IF (PRESENT(nconstraint_fixd)) THEN
     602       279724 :          nconstraint_fixd = 0
     603       279724 :          IF (molecule_kind%nfixd /= 0) THEN
     604       171910 :             DO i = 1, SIZE(molecule_kind%fixd_list)
     605       170016 :                IF (molecule_kind%fixd_list(i)%restraint%active) CYCLE
     606         1894 :                SELECT CASE (molecule_kind%fixd_list(i)%itype)
     607              :                CASE (use_perd_x, use_perd_y, use_perd_z)
     608        62976 :                   nconstraint_fixd = nconstraint_fixd + 1
     609              :                CASE (use_perd_xy, use_perd_xz, use_perd_yz)
     610        20992 :                   nconstraint_fixd = nconstraint_fixd + 2
     611              :                CASE (use_perd_xyz)
     612       169588 :                   nconstraint_fixd = nconstraint_fixd + 3
     613              :                END SELECT
     614              :             END DO
     615              :          END IF
     616              :       END IF
     617     16468556 :       IF (PRESENT(ng3x3_restraint)) ng3x3_restraint = molecule_kind%ng3x3_restraint
     618     16468556 :       IF (PRESENT(ng4x6_restraint)) ng4x6_restraint = molecule_kind%ng4x6_restraint
     619     16468556 :       IF (PRESENT(nvsite_restraint)) nvsite_restraint = molecule_kind%nvsite_restraint
     620     16468556 :       IF (PRESENT(nfixd_restraint)) nfixd_restraint = molecule_kind%nfixd_restraint
     621     16468556 :       IF (PRESENT(nrestraints)) nrestraints = molecule_kind%ncolv%nrestraint + &
     622              :                                               molecule_kind%ng3x3_restraint + &
     623              :                                               molecule_kind%ng4x6_restraint + &
     624       264756 :                                               molecule_kind%nvsite_restraint
     625     16468556 :       IF (PRESENT(nmolecule)) nmolecule = molecule_kind%nmolecule
     626     16468556 :       IF (PRESENT(nshell)) nshell = molecule_kind%nshell
     627     16468556 :       IF (PRESENT(ntorsion)) ntorsion = molecule_kind%ntorsion
     628     16468556 :       IF (PRESENT(nsgf)) nsgf = molecule_kind%nsgf
     629     16468556 :       IF (PRESENT(nelectron)) nelectron = molecule_kind%nelectron
     630     16468556 :       IF (PRESENT(nelectron_alpha)) nelectron_alpha = molecule_kind%nelectron_beta
     631     16468556 :       IF (PRESENT(nelectron_beta)) nelectron_beta = molecule_kind%nelectron_alpha
     632     16468556 :       IF (PRESENT(molecule_list)) molecule_list => molecule_kind%molecule_list
     633              : 
     634     16468556 :    END SUBROUTINE get_molecule_kind
     635              : 
     636              : ! **************************************************************************************************
     637              : !> \brief   Get informations about a molecule kind set.
     638              : !> \param molecule_kind_set ...
     639              : !> \param maxatom ...
     640              : !> \param natom ...
     641              : !> \param nbond ...
     642              : !> \param nbend ...
     643              : !> \param nub ...
     644              : !> \param ntorsion ...
     645              : !> \param nimpr ...
     646              : !> \param nopbend ...
     647              : !> \param nconstraint ...
     648              : !> \param nconstraint_fixd ...
     649              : !> \param nmolecule ...
     650              : !> \param nrestraints ...
     651              : !> \date    27.08.2003
     652              : !> \author  Matthias Krack
     653              : !> \version 1.0
     654              : ! **************************************************************************************************
     655        49032 :    SUBROUTINE get_molecule_kind_set(molecule_kind_set, maxatom, natom, &
     656              :                                     nbond, nbend, nub, ntorsion, nimpr, nopbend, &
     657              :                                     nconstraint, nconstraint_fixd, nmolecule, &
     658              :                                     nrestraints)
     659              : 
     660              :       TYPE(molecule_kind_type), DIMENSION(:), INTENT(IN) :: molecule_kind_set
     661              :       INTEGER, INTENT(OUT), OPTIONAL                     :: maxatom, natom, nbond, nbend, nub, &
     662              :                                                             ntorsion, nimpr, nopbend, nconstraint, &
     663              :                                                             nconstraint_fixd, nmolecule, &
     664              :                                                             nrestraints
     665              : 
     666              :       INTEGER :: ibend, ibond, iimpr, imolecule_kind, iopbend, itorsion, iub, na, nc, nc_fixd, &
     667              :          nfixd_restraint, nm, nmolecule_kind, nrestraints_tot
     668              : 
     669        49032 :       IF (PRESENT(maxatom)) maxatom = 0
     670        49032 :       IF (PRESENT(natom)) natom = 0
     671        49032 :       IF (PRESENT(nbond)) nbond = 0
     672        49032 :       IF (PRESENT(nbend)) nbend = 0
     673        49032 :       IF (PRESENT(nub)) nub = 0
     674        49032 :       IF (PRESENT(ntorsion)) ntorsion = 0
     675        49032 :       IF (PRESENT(nimpr)) nimpr = 0
     676        49032 :       IF (PRESENT(nopbend)) nopbend = 0
     677        49032 :       IF (PRESENT(nconstraint)) nconstraint = 0
     678        49032 :       IF (PRESENT(nconstraint_fixd)) nconstraint_fixd = 0
     679        49032 :       IF (PRESENT(nrestraints)) nrestraints = 0
     680        49032 :       IF (PRESENT(nmolecule)) nmolecule = 0
     681              : 
     682        49032 :       nmolecule_kind = SIZE(molecule_kind_set)
     683              : 
     684       313788 :       DO imolecule_kind = 1, nmolecule_kind
     685        49032 :          ASSOCIATE (molecule_kind => molecule_kind_set(imolecule_kind))
     686              : 
     687              :             CALL get_molecule_kind(molecule_kind=molecule_kind, &
     688              :                                    natom=na, &
     689              :                                    nbond=ibond, &
     690              :                                    nbend=ibend, &
     691              :                                    nub=iub, &
     692              :                                    ntorsion=itorsion, &
     693              :                                    nimpr=iimpr, &
     694              :                                    nopbend=iopbend, &
     695              :                                    nconstraint=nc, &
     696              :                                    nconstraint_fixd=nc_fixd, &
     697              :                                    nfixd_restraint=nfixd_restraint, &
     698              :                                    nrestraints=nrestraints_tot, &
     699       264756 :                                    nmolecule=nm)
     700       264756 :             IF (PRESENT(maxatom)) maxatom = MAX(maxatom, na)
     701       264756 :             IF (PRESENT(natom)) natom = natom + na*nm
     702       264756 :             IF (PRESENT(nbond)) nbond = nbond + ibond*nm
     703       264756 :             IF (PRESENT(nbend)) nbend = nbend + ibend*nm
     704       264756 :             IF (PRESENT(nub)) nub = nub + iub*nm
     705       264756 :             IF (PRESENT(ntorsion)) ntorsion = ntorsion + itorsion*nm
     706       264756 :             IF (PRESENT(nimpr)) nimpr = nimpr + iimpr*nm
     707       264756 :             IF (PRESENT(nopbend)) nopbend = nopbend + iopbend*nm
     708       264756 :             IF (PRESENT(nconstraint)) nconstraint = nconstraint + nc*nm + nc_fixd
     709       264756 :             IF (PRESENT(nconstraint_fixd)) nconstraint_fixd = nconstraint_fixd + nc_fixd
     710       264756 :             IF (PRESENT(nmolecule)) nmolecule = nmolecule + nm
     711       529512 :             IF (PRESENT(nrestraints)) nrestraints = nrestraints + nm*nrestraints_tot + nfixd_restraint
     712              : 
     713              :          END ASSOCIATE
     714              :       END DO
     715              : 
     716        49032 :    END SUBROUTINE get_molecule_kind_set
     717              : 
     718              : ! **************************************************************************************************
     719              : !> \brief   Set the components of a molecule kind.
     720              : !> \param molecule_kind ...
     721              : !> \param name ...
     722              : !> \param mass ...
     723              : !> \param charge ...
     724              : !> \param kind_number ...
     725              : !> \param molecule_list ...
     726              : !> \param atom_list ...
     727              : !> \param nbond ...
     728              : !> \param bond_list ...
     729              : !> \param nbend ...
     730              : !> \param bend_list ...
     731              : !> \param nub ...
     732              : !> \param ub_list ...
     733              : !> \param nimpr ...
     734              : !> \param impr_list ...
     735              : !> \param nopbend ...
     736              : !> \param opbend_list ...
     737              : !> \param ntorsion ...
     738              : !> \param torsion_list ...
     739              : !> \param fixd_list ...
     740              : !> \param ncolv ...
     741              : !> \param colv_list ...
     742              : !> \param ng3x3 ...
     743              : !> \param g3x3_list ...
     744              : !> \param ng4x6 ...
     745              : !> \param nfixd ...
     746              : !> \param g4x6_list ...
     747              : !> \param nvsite ...
     748              : !> \param vsite_list ...
     749              : !> \param ng3x3_restraint ...
     750              : !> \param ng4x6_restraint ...
     751              : !> \param nfixd_restraint ...
     752              : !> \param nshell ...
     753              : !> \param shell_list ...
     754              : !> \param nvsite_restraint ...
     755              : !> \param bond_kind_set ...
     756              : !> \param bend_kind_set ...
     757              : !> \param ub_kind_set ...
     758              : !> \param torsion_kind_set ...
     759              : !> \param impr_kind_set ...
     760              : !> \param opbend_kind_set ...
     761              : !> \param nelectron ...
     762              : !> \param nsgf ...
     763              : !> \param molname_generated ...
     764              : !> \date    27.08.2003
     765              : !> \author  Matthias Krack
     766              : !> \version 1.0
     767              : ! **************************************************************************************************
     768      2055743 :    SUBROUTINE set_molecule_kind(molecule_kind, name, mass, charge, kind_number, &
     769              :                                 molecule_list, atom_list, nbond, bond_list, &
     770              :                                 nbend, bend_list, nub, ub_list, nimpr, impr_list, &
     771              :                                 nopbend, opbend_list, ntorsion, &
     772              :                                 torsion_list, fixd_list, ncolv, colv_list, ng3x3, &
     773              :                                 g3x3_list, ng4x6, nfixd, g4x6_list, nvsite, &
     774              :                                 vsite_list, ng3x3_restraint, ng4x6_restraint, &
     775              :                                 nfixd_restraint, nshell, shell_list, &
     776              :                                 nvsite_restraint, bond_kind_set, bend_kind_set, &
     777              :                                 ub_kind_set, torsion_kind_set, impr_kind_set, &
     778              :                                 opbend_kind_set, nelectron, nsgf, &
     779              :                                 molname_generated)
     780              : 
     781              :       TYPE(molecule_kind_type), INTENT(INOUT)            :: molecule_kind
     782              :       CHARACTER(LEN=*), INTENT(IN), OPTIONAL             :: name
     783              :       REAL(KIND=dp), OPTIONAL                            :: mass, charge
     784              :       INTEGER, INTENT(IN), OPTIONAL                      :: kind_number
     785              :       INTEGER, DIMENSION(:), OPTIONAL, POINTER           :: molecule_list
     786              :       TYPE(atom_type), DIMENSION(:), OPTIONAL, POINTER   :: atom_list
     787              :       INTEGER, INTENT(IN), OPTIONAL                      :: nbond
     788              :       TYPE(bond_type), DIMENSION(:), OPTIONAL, POINTER   :: bond_list
     789              :       INTEGER, INTENT(IN), OPTIONAL                      :: nbend
     790              :       TYPE(bend_type), DIMENSION(:), OPTIONAL, POINTER   :: bend_list
     791              :       INTEGER, INTENT(IN), OPTIONAL                      :: nub
     792              :       TYPE(ub_type), DIMENSION(:), OPTIONAL, POINTER     :: ub_list
     793              :       INTEGER, INTENT(IN), OPTIONAL                      :: nimpr
     794              :       TYPE(impr_type), DIMENSION(:), OPTIONAL, POINTER   :: impr_list
     795              :       INTEGER, INTENT(IN), OPTIONAL                      :: nopbend
     796              :       TYPE(opbend_type), DIMENSION(:), OPTIONAL, POINTER :: opbend_list
     797              :       INTEGER, INTENT(IN), OPTIONAL                      :: ntorsion
     798              :       TYPE(torsion_type), DIMENSION(:), OPTIONAL, &
     799              :          POINTER                                         :: torsion_list
     800              :       TYPE(fixd_constraint_type), DIMENSION(:), &
     801              :          OPTIONAL, POINTER                               :: fixd_list
     802              :       TYPE(colvar_counters), INTENT(IN), OPTIONAL        :: ncolv
     803              :       TYPE(colvar_constraint_type), DIMENSION(:), &
     804              :          OPTIONAL, POINTER                               :: colv_list
     805              :       INTEGER, INTENT(IN), OPTIONAL                      :: ng3x3
     806              :       TYPE(g3x3_constraint_type), DIMENSION(:), &
     807              :          OPTIONAL, POINTER                               :: g3x3_list
     808              :       INTEGER, INTENT(IN), OPTIONAL                      :: ng4x6, nfixd
     809              :       TYPE(g4x6_constraint_type), DIMENSION(:), &
     810              :          OPTIONAL, POINTER                               :: g4x6_list
     811              :       INTEGER, INTENT(IN), OPTIONAL                      :: nvsite
     812              :       TYPE(vsite_constraint_type), DIMENSION(:), &
     813              :          OPTIONAL, POINTER                               :: vsite_list
     814              :       INTEGER, INTENT(IN), OPTIONAL                      :: ng3x3_restraint, ng4x6_restraint, &
     815              :                                                             nfixd_restraint, nshell
     816              :       TYPE(shell_type), DIMENSION(:), OPTIONAL, POINTER  :: shell_list
     817              :       INTEGER, INTENT(IN), OPTIONAL                      :: nvsite_restraint
     818              :       TYPE(bond_kind_type), DIMENSION(:), OPTIONAL, &
     819              :          POINTER                                         :: bond_kind_set
     820              :       TYPE(bend_kind_type), DIMENSION(:), OPTIONAL, &
     821              :          POINTER                                         :: bend_kind_set
     822              :       TYPE(ub_kind_type), DIMENSION(:), OPTIONAL, &
     823              :          POINTER                                         :: ub_kind_set
     824              :       TYPE(torsion_kind_type), DIMENSION(:), OPTIONAL, &
     825              :          POINTER                                         :: torsion_kind_set
     826              :       TYPE(impr_kind_type), DIMENSION(:), OPTIONAL, &
     827              :          POINTER                                         :: impr_kind_set
     828              :       TYPE(opbend_kind_type), DIMENSION(:), OPTIONAL, &
     829              :          POINTER                                         :: opbend_kind_set
     830              :       INTEGER, INTENT(IN), OPTIONAL                      :: nelectron, nsgf
     831              :       LOGICAL, INTENT(IN), OPTIONAL                      :: molname_generated
     832              : 
     833              :       INTEGER                                            :: n
     834              : 
     835      2055743 :       IF (PRESENT(atom_list)) THEN
     836       272858 :          n = SIZE(atom_list)
     837       272858 :          molecule_kind%natom = n
     838       272858 :          molecule_kind%atom_list => atom_list
     839              :       END IF
     840      2055743 :       IF (PRESENT(molname_generated)) molecule_kind%molname_generated = molname_generated
     841      2055743 :       IF (PRESENT(name)) molecule_kind%name = name
     842      2055743 :       IF (PRESENT(mass)) molecule_kind%mass = mass
     843      2055743 :       IF (PRESENT(charge)) molecule_kind%charge = charge
     844      2055743 :       IF (PRESENT(kind_number)) molecule_kind%kind_number = kind_number
     845      2055743 :       IF (PRESENT(nbond)) molecule_kind%nbond = nbond
     846      2055743 :       IF (PRESENT(bond_list)) molecule_kind%bond_list => bond_list
     847      2055743 :       IF (PRESENT(nbend)) molecule_kind%nbend = nbend
     848      2055743 :       IF (PRESENT(nelectron)) molecule_kind%nelectron = nelectron
     849      2055743 :       IF (PRESENT(nsgf)) molecule_kind%nsgf = nsgf
     850      2055743 :       IF (PRESENT(bend_list)) molecule_kind%bend_list => bend_list
     851      2055743 :       IF (PRESENT(nub)) molecule_kind%nub = nub
     852      2055743 :       IF (PRESENT(ub_list)) molecule_kind%ub_list => ub_list
     853      2055743 :       IF (PRESENT(ntorsion)) molecule_kind%ntorsion = ntorsion
     854      2055743 :       IF (PRESENT(torsion_list)) molecule_kind%torsion_list => torsion_list
     855      2055743 :       IF (PRESENT(nimpr)) molecule_kind%nimpr = nimpr
     856      2055743 :       IF (PRESENT(impr_list)) molecule_kind%impr_list => impr_list
     857      2055743 :       IF (PRESENT(nopbend)) molecule_kind%nopbend = nopbend
     858      2055743 :       IF (PRESENT(opbend_list)) molecule_kind%opbend_list => opbend_list
     859      2055743 :       IF (PRESENT(ncolv)) molecule_kind%ncolv = ncolv
     860      2055743 :       IF (PRESENT(colv_list)) molecule_kind%colv_list => colv_list
     861      2055743 :       IF (PRESENT(ng3x3)) molecule_kind%ng3x3 = ng3x3
     862      2055743 :       IF (PRESENT(g3x3_list)) molecule_kind%g3x3_list => g3x3_list
     863      2055743 :       IF (PRESENT(ng4x6)) molecule_kind%ng4x6 = ng4x6
     864      2055743 :       IF (PRESENT(nvsite)) molecule_kind%nvsite = nvsite
     865      2055743 :       IF (PRESENT(nfixd)) molecule_kind%nfixd = nfixd
     866      2055743 :       IF (PRESENT(nfixd_restraint)) molecule_kind%nfixd_restraint = nfixd_restraint
     867      2055743 :       IF (PRESENT(ng3x3_restraint)) molecule_kind%ng3x3_restraint = ng3x3_restraint
     868      2055743 :       IF (PRESENT(ng4x6_restraint)) molecule_kind%ng4x6_restraint = ng4x6_restraint
     869      2055743 :       IF (PRESENT(nvsite_restraint)) molecule_kind%nvsite_restraint = nvsite_restraint
     870      2055743 :       IF (PRESENT(g4x6_list)) molecule_kind%g4x6_list => g4x6_list
     871      2055743 :       IF (PRESENT(vsite_list)) molecule_kind%vsite_list => vsite_list
     872      2055743 :       IF (PRESENT(fixd_list)) molecule_kind%fixd_list => fixd_list
     873      2055743 :       IF (PRESENT(bond_kind_set)) molecule_kind%bond_kind_set => bond_kind_set
     874      2055743 :       IF (PRESENT(bend_kind_set)) molecule_kind%bend_kind_set => bend_kind_set
     875      2055743 :       IF (PRESENT(ub_kind_set)) molecule_kind%ub_kind_set => ub_kind_set
     876      2055743 :       IF (PRESENT(torsion_kind_set)) molecule_kind%torsion_kind_set => torsion_kind_set
     877      2055743 :       IF (PRESENT(impr_kind_set)) molecule_kind%impr_kind_set => impr_kind_set
     878      2055743 :       IF (PRESENT(opbend_kind_set)) molecule_kind%opbend_kind_set => opbend_kind_set
     879      2055743 :       IF (PRESENT(nshell)) molecule_kind%nshell = nshell
     880      2055743 :       IF (PRESENT(shell_list)) molecule_kind%shell_list => shell_list
     881      2055743 :       IF (PRESENT(molecule_list)) THEN
     882       136429 :          n = SIZE(molecule_list)
     883       136429 :          molecule_kind%nmolecule = n
     884       136429 :          molecule_kind%molecule_list => molecule_list
     885              :       END IF
     886      2055743 :    END SUBROUTINE set_molecule_kind
     887              : 
     888              : ! **************************************************************************************************
     889              : !> \brief   Write a molecule kind data set to the output unit.
     890              : !> \param molecule_kind ...
     891              : !> \param output_unit ...
     892              : !> \date    24.09.2003
     893              : !> \author  Matthias Krack
     894              : !> \version 1.0
     895              : ! **************************************************************************************************
     896         2231 :    SUBROUTINE write_molecule_kind(molecule_kind, output_unit)
     897              :       TYPE(molecule_kind_type), INTENT(IN)               :: molecule_kind
     898              :       INTEGER, INTENT(in)                                :: output_unit
     899              : 
     900              :       CHARACTER(LEN=default_string_length)               :: name
     901              :       INTEGER                                            :: iatom, imolecule, natom, nmolecule
     902              :       TYPE(atomic_kind_type), POINTER                    :: atomic_kind
     903              : 
     904         2231 :       IF (output_unit > 0) THEN
     905         2231 :          natom = SIZE(molecule_kind%atom_list)
     906         2231 :          nmolecule = SIZE(molecule_kind%molecule_list)
     907              : 
     908         2231 :          IF (natom == 1) THEN
     909          211 :             atomic_kind => molecule_kind%atom_list(1)%atomic_kind
     910          211 :             CALL get_atomic_kind(atomic_kind=atomic_kind, name=name)
     911              :             WRITE (UNIT=output_unit, FMT="(/,T2,I5,A,T36,A,A,T64,A)") &
     912          211 :                molecule_kind%kind_number, &
     913          211 :                ". Molecule kind: "//TRIM(molecule_kind%name), &
     914          422 :                "Atomic kind name:   ", TRIM(name)
     915              :             WRITE (UNIT=output_unit, FMT="(T9,A,L1,T55,A,T75,I6)") &
     916          211 :                "Automatic name: ", molecule_kind%molname_generated, &
     917          422 :                "Number of molecules:", nmolecule
     918              :          ELSE
     919              :             WRITE (UNIT=output_unit, FMT="(/,T2,I5,A,T50,A,T75,I6,/,T22,A)") &
     920         2020 :                molecule_kind%kind_number, &
     921         2020 :                ". Molecule kind: "//TRIM(molecule_kind%name), &
     922         2020 :                "Number of atoms:    ", natom, &
     923         4040 :                "Atom         Atomic kind name"
     924        16725 :             DO iatom = 1, natom
     925        14705 :                atomic_kind => molecule_kind%atom_list(iatom)%atomic_kind
     926        14705 :                CALL get_atomic_kind(atomic_kind=atomic_kind, name=name)
     927              :                WRITE (UNIT=output_unit, FMT="(T20,I6,(7X,A18))") &
     928        16725 :                   iatom, TRIM(name)
     929              :             END DO
     930              :             WRITE (UNIT=output_unit, FMT="(/,T9,A,L1)") &
     931         2020 :                "The name was automatically generated: ", &
     932         4040 :                molecule_kind%molname_generated
     933              :             WRITE (UNIT=output_unit, FMT="(T9,A,I6,/,T9,A,(T30,5I10))") &
     934         2020 :                "Number of molecules: ", nmolecule, "Molecule list:", &
     935        33828 :                (molecule_kind%molecule_list(imolecule), imolecule=1, nmolecule)
     936         2020 :             IF (molecule_kind%nbond > 0) &
     937              :                WRITE (UNIT=output_unit, FMT="(1X,A30,I6)") &
     938         1744 :                "Number of bonds:       ", molecule_kind%nbond
     939         2020 :             IF (molecule_kind%nbend > 0) &
     940              :                WRITE (UNIT=output_unit, FMT="(1X,A30,I6)") &
     941         1618 :                "Number of bends:       ", molecule_kind%nbend
     942         2020 :             IF (molecule_kind%nub > 0) &
     943              :                WRITE (UNIT=output_unit, FMT="(1X,A30,I6)") &
     944          266 :                "Number of Urey-Bradley:", molecule_kind%nub
     945         2020 :             IF (molecule_kind%ntorsion > 0) &
     946              :                WRITE (UNIT=output_unit, FMT="(1X,A30,I6)") &
     947         1122 :                "Number of torsions:    ", molecule_kind%ntorsion
     948         2020 :             IF (molecule_kind%nimpr > 0) &
     949              :                WRITE (UNIT=output_unit, FMT="(1X,A30,I6)") &
     950          179 :                "Number of improper:    ", molecule_kind%nimpr
     951         2020 :             IF (molecule_kind%nopbend > 0) &
     952              :                WRITE (UNIT=output_unit, FMT="(1X,A30,I6)") &
     953            4 :                "Number of out opbends:    ", molecule_kind%nopbend
     954              :          END IF
     955              :       END IF
     956         2231 :    END SUBROUTINE write_molecule_kind
     957              : 
     958              : ! **************************************************************************************************
     959              : !> \brief   Write a moleculeatomic kind set data set to the output unit.
     960              : !> \param molecule_kind_set ...
     961              : !> \param subsys_section ...
     962              : !> \date    24.09.2003
     963              : !> \author  Matthias Krack
     964              : !> \version 1.0
     965              : ! **************************************************************************************************
     966        10251 :    SUBROUTINE write_molecule_kind_set(molecule_kind_set, subsys_section)
     967              :       TYPE(molecule_kind_type), DIMENSION(:), INTENT(IN) :: molecule_kind_set
     968              :       TYPE(section_vals_type), INTENT(IN)                :: subsys_section
     969              : 
     970              :       CHARACTER(len=*), PARAMETER :: routineN = 'write_molecule_kind_set'
     971              : 
     972              :       INTEGER                                            :: handle, imolecule_kind, natom, nbend, &
     973              :                                                             nbond, nimpr, nmolecule, &
     974              :                                                             nmolecule_kind, nopbend, ntors, &
     975              :                                                             ntotal, nub, output_unit
     976              :       LOGICAL                                            :: all_single_atoms
     977              :       TYPE(cp_logger_type), POINTER                      :: logger
     978              : 
     979        10251 :       CALL timeset(routineN, handle)
     980              : 
     981        10251 :       NULLIFY (logger)
     982        10251 :       logger => cp_get_default_logger()
     983              :       output_unit = cp_print_key_unit_nr(logger, subsys_section, &
     984        10251 :                                          "PRINT%MOLECULES", extension=".Log")
     985        10251 :       IF (output_unit > 0) THEN
     986         2589 :          WRITE (UNIT=output_unit, FMT="(/,/,T2,A)") "MOLECULE KIND INFORMATION"
     987              : 
     988         2589 :          nmolecule_kind = SIZE(molecule_kind_set)
     989              : 
     990         2589 :          all_single_atoms = .TRUE.
     991        31914 :          DO imolecule_kind = 1, nmolecule_kind
     992        29325 :             natom = SIZE(molecule_kind_set(imolecule_kind)%atom_list)
     993        29325 :             nmolecule = SIZE(molecule_kind_set(imolecule_kind)%molecule_list)
     994        31914 :             IF (natom*nmolecule > 1) all_single_atoms = .FALSE.
     995              :          END DO
     996              : 
     997         2589 :          IF (all_single_atoms) THEN
     998              :             WRITE (UNIT=output_unit, FMT="(/,/,T2,A)") &
     999         1900 :                "All atoms are their own molecule, skipping detailed information"
    1000              :          ELSE
    1001         2920 :             DO imolecule_kind = 1, nmolecule_kind
    1002         2920 :                CALL write_molecule_kind(molecule_kind_set(imolecule_kind), output_unit)
    1003              :             END DO
    1004              :          END IF
    1005              : 
    1006              :          CALL get_molecule_kind_set(molecule_kind_set=molecule_kind_set, &
    1007              :                                     nbond=nbond, &
    1008              :                                     nbend=nbend, &
    1009              :                                     nub=nub, &
    1010              :                                     ntorsion=ntors, &
    1011              :                                     nimpr=nimpr, &
    1012         2589 :                                     nopbend=nopbend)
    1013         2589 :          ntotal = nbond + nbend + nub + ntors + nimpr + nopbend
    1014         2589 :          IF (ntotal > 0) THEN
    1015              :             WRITE (UNIT=output_unit, FMT="(/,/,T2,A,T45,A30,I6)") &
    1016          587 :                "MOLECULE KIND SET INFORMATION", &
    1017         1174 :                "Total Number of bonds:       ", nbond
    1018              :             WRITE (UNIT=output_unit, FMT="(T45,A30,I6)") &
    1019          587 :                "Total Number of bends:       ", nbend
    1020              :             WRITE (UNIT=output_unit, FMT="(T45,A30,I6)") &
    1021          587 :                "Total Number of Urey-Bradley:", nub
    1022              :             WRITE (UNIT=output_unit, FMT="(T45,A30,I6)") &
    1023          587 :                "Total Number of torsions:    ", ntors
    1024              :             WRITE (UNIT=output_unit, FMT="(T45,A30,I6)") &
    1025          587 :                "Total Number of improper:    ", nimpr
    1026              :             WRITE (UNIT=output_unit, FMT="(T45,A30,I6)") &
    1027          587 :                "Total Number of opbends:    ", nopbend
    1028              :          END IF
    1029              :       END IF
    1030              :       CALL cp_print_key_finished_output(output_unit, logger, subsys_section, &
    1031        10251 :                                         "PRINT%MOLECULES")
    1032              : 
    1033        10251 :       CALL timestop(handle)
    1034              : 
    1035        10251 :    END SUBROUTINE write_molecule_kind_set
    1036              : 
    1037              : ! **************************************************************************************************
    1038              : !> \brief Write collective variable constraint information to output unit
    1039              : !> \param colvar_constraint Data set of the collective variable constraint
    1040              : !> \param icolv Collective variable number (index)
    1041              : !> \param iw Logical unit number of the output unit
    1042              : !> \author Matthias Krack (25.11.2025)
    1043              : ! **************************************************************************************************
    1044           26 :    SUBROUTINE write_colvar_constraint(colvar_constraint, icolv, iw)
    1045              : 
    1046              :       TYPE(colvar_constraint_type), INTENT(IN), POINTER  :: colvar_constraint
    1047              :       INTEGER, INTENT(IN)                                :: icolv, iw
    1048              : 
    1049              :       CHARACTER(LEN=30)                                  :: type_string
    1050              : 
    1051           26 :       IF (iw > 0) THEN
    1052           26 :          CPASSERT(ASSOCIATED(colvar_constraint))
    1053              :          WRITE (UNIT=iw, FMT="(/,T2,A,T71,I10)") &
    1054           26 :             "COLVAR| Number", icolv
    1055           26 :          SELECT CASE (colvar_constraint%type_id)
    1056              :          CASE (no_colvar_id)
    1057            0 :             type_string = "Undefined"
    1058              :          CASE (dist_colvar_id)
    1059           19 :             type_string = "Distance"
    1060              :          CASE (coord_colvar_id)
    1061            1 :             type_string = "Coordination number"
    1062              :          CASE (torsion_colvar_id)
    1063            0 :             type_string = "Torsion"
    1064              :          CASE (angle_colvar_id)
    1065            2 :             type_string = "Angle"
    1066              :          CASE (plane_distance_colvar_id)
    1067            0 :             type_string = "Plane distance"
    1068              :          CASE (rotation_colvar_id)
    1069            0 :             type_string = "Rotation"
    1070              :          CASE (dfunct_colvar_id)
    1071            2 :             type_string = "Distance function"
    1072              :          CASE (qparm_colvar_id)
    1073            0 :             type_string = "Q parameter"
    1074              :          CASE (hydronium_shell_colvar_id)
    1075            0 :             type_string = "Hydronium shell"
    1076              :          CASE (reaction_path_colvar_id)
    1077            0 :             type_string = "Reaction path"
    1078              :          CASE (combine_colvar_id)
    1079            0 :             type_string = "Combine"
    1080              :          CASE (population_colvar_id)
    1081            0 :             type_string = "Population"
    1082              :          CASE (plane_plane_angle_colvar_id)
    1083            2 :             type_string = "Angle plane-plane"
    1084              :          CASE (gyration_colvar_id)
    1085            0 :             type_string = "Gyration radius"
    1086              :          CASE (rmsd_colvar_id)
    1087            0 :             type_string = "RMSD"
    1088              :          CASE (distance_from_path_colvar_id)
    1089            0 :             type_string = "Distance from path"
    1090              :          CASE (xyz_diag_colvar_id)
    1091            0 :             type_string = "XYZ diag"
    1092              :          CASE (xyz_outerdiag_colvar_id)
    1093            0 :             type_string = "XYZ outerdiag"
    1094              :          CASE (u_colvar_id)
    1095            0 :             type_string = "U"
    1096              :          CASE (Wc_colvar_id)
    1097            0 :             type_string = "WC"
    1098              :          CASE (HBP_colvar_id)
    1099            0 :             type_string = "HBP"
    1100              :          CASE (ring_puckering_colvar_id)
    1101            0 :             type_string = "Ring puckering"
    1102              :          CASE (mindist_colvar_id)
    1103            0 :             type_string = "Distance point-plane"
    1104              :          CASE (acid_hyd_dist_colvar_id)
    1105            0 :             type_string = "Acid hydronium distance"
    1106              :          CASE (acid_hyd_shell_colvar_id)
    1107            0 :             type_string = "Acid hydronium shell"
    1108              :          CASE (hydronium_dist_colvar_id)
    1109            0 :             type_string = "Hydronium distance"
    1110              :          CASE DEFAULT
    1111           26 :             CPABORT("Invalid collective variable ID specified. Check the code!")
    1112              :          END SELECT
    1113           26 :          IF (colvar_constraint%restraint%active) THEN
    1114              :             WRITE (UNIT=iw, FMT="(T2,A,T51,A30)") &
    1115            7 :                "COLVAR| Restraint type", ADJUSTR(TRIM(type_string))
    1116              :             WRITE (UNIT=iw, FMT="(T2,A,T66,ES15.6)") &
    1117            7 :                "COLVAR| Restraint constant k [a.u.]", colvar_constraint%restraint%k0
    1118              :          ELSE
    1119              :             WRITE (UNIT=iw, FMT="(T2,A,T51,A30)") &
    1120           19 :                "COLVAR| Constraint type", ADJUSTR(TRIM(type_string))
    1121              :          END IF
    1122              :          WRITE (UNIT=iw, FMT="(T2,A,T66,ES15.6)") &
    1123           26 :             "COLVAR| Target value", colvar_constraint%expected_value, &
    1124           52 :             "COLVAR| Target value growth speed", colvar_constraint%expected_value_growth_speed
    1125           26 :          IF (colvar_constraint%use_points) THEN
    1126            4 :             WRITE (UNIT=iw, FMT="(T2,A,T78,A3)") "COLVAR| Use points", "Yes"
    1127              :          ELSE
    1128           22 :             WRITE (UNIT=iw, FMT="(T2,A,T79,A2)") "COLVAR| Use points", "No"
    1129              :          END IF
    1130              :       END IF
    1131              : 
    1132           26 :    END SUBROUTINE write_colvar_constraint
    1133              : 
    1134              : ! **************************************************************************************************
    1135              : !> \brief Write fix atom constraint information to output unit
    1136              : !> \param fixd_constraint Data set of the fix atom constraint
    1137              : !> \param ifixd Fix atom constraint/restraint number (index)
    1138              : !> \param iw Logical unit number of the output unit
    1139              : !> \author Matthias Krack (26.11.2025)
    1140              : ! **************************************************************************************************
    1141            2 :    SUBROUTINE write_fixd_constraint(fixd_constraint, ifixd, iw)
    1142              : 
    1143              :       TYPE(fixd_constraint_type), INTENT(IN), POINTER    :: fixd_constraint
    1144              :       INTEGER, INTENT(IN)                                :: ifixd, iw
    1145              : 
    1146            2 :       IF (iw > 0) THEN
    1147            2 :          CPASSERT(ASSOCIATED(fixd_constraint))
    1148            2 :          IF (fixd_constraint%restraint%active) THEN
    1149              :             WRITE (UNIT=iw, FMT="(/,T2,A,T71,I10)") &
    1150            2 :                "FIX_ATOM| Number (restraint)", ifixd
    1151              :             WRITE (UNIT=iw, FMT="(T2,A,T66,ES15.6)") &
    1152            2 :                "FIX_ATOM| Restraint constant k [a.u.]", fixd_constraint%restraint%k0
    1153              :          ELSE
    1154              :             WRITE (UNIT=iw, FMT="(/,T2,A,T71,I10)") &
    1155            0 :                "FIX_ATOM| Number (constraint)", ifixd
    1156              :          END IF
    1157              :          WRITE (UNIT=iw, FMT="(T2,A,T71,I10)") &
    1158            2 :             "FIX_ATOM| Atom index", fixd_constraint%fixd
    1159              :          WRITE (UNIT=iw, FMT="(T2,A,T78,A3)") &
    1160            2 :             "FIX_ATOM| Fixed Cartesian components", periodicity_string(fixd_constraint%itype)
    1161            2 :          IF (INDEX(periodicity_string(fixd_constraint%itype), "X") > 0) THEN
    1162              :             WRITE (UNIT=iw, FMT="(T2,A,T66,F15.8)") &
    1163            2 :                "FIX_ATOM| X coordinate [Angstrom]", cp_unit_from_cp2k(fixd_constraint%coord(1), "Angstrom")
    1164              :          END IF
    1165            2 :          IF (INDEX(periodicity_string(fixd_constraint%itype), "Y") > 0) THEN
    1166              :             WRITE (UNIT=iw, FMT="(T2,A,T66,F15.8)") &
    1167            2 :                "FIX_ATOM| Y coordinate [Angstrom]", cp_unit_from_cp2k(fixd_constraint%coord(2), "Angstrom")
    1168              :          END IF
    1169            2 :          IF (INDEX(periodicity_string(fixd_constraint%itype), "Z") > 0) THEN
    1170              :             WRITE (UNIT=iw, FMT="(T2,A,T66,F15.8)") &
    1171            2 :                "FIX_ATOM| Z coordinate [Angstrom]", cp_unit_from_cp2k(fixd_constraint%coord(3), "Angstrom")
    1172              :          END IF
    1173              :       END IF
    1174              : 
    1175            2 :    END SUBROUTINE write_fixd_constraint
    1176              : 
    1177              : ! **************************************************************************************************
    1178              : !> \brief Write G3x3 constraint information to output unit
    1179              : !> \param g3x3_constraint Data set of the g3x3 constraint
    1180              : !> \param ig3x3 G3x3 constraint/restraint number (index)
    1181              : !> \param iw Logical unit number of the output unit
    1182              : !> \author Matthias Krack (26.11.2025)
    1183              : ! **************************************************************************************************
    1184            2 :    SUBROUTINE write_g3x3_constraint(g3x3_constraint, ig3x3, iw)
    1185              : 
    1186              :       TYPE(g3x3_constraint_type), INTENT(IN), POINTER    :: g3x3_constraint
    1187              :       INTEGER, INTENT(IN)                                :: ig3x3, iw
    1188              : 
    1189            2 :       IF (iw > 0) THEN
    1190            2 :          CPASSERT(ASSOCIATED(g3x3_constraint))
    1191            2 :          IF (g3x3_constraint%restraint%active) THEN
    1192              :             WRITE (UNIT=iw, FMT="(/,T2,A,T71,I10)") &
    1193            1 :                "G3X3| Number (restraint)", ig3x3
    1194              :             WRITE (UNIT=iw, FMT="(T2,A,T66,ES15.6)") &
    1195            1 :                "G3X3| Restraint constant k [a.u.]", g3x3_constraint%restraint%k0
    1196              :          ELSE
    1197              :             WRITE (UNIT=iw, FMT="(/,T2,A,T71,I10)") &
    1198            1 :                "G3X3| Number (constraint)", ig3x3
    1199              :          END IF
    1200              :          WRITE (UNIT=iw, FMT="(T2,A,T71,I10)") &
    1201            2 :             "G3X3| Atom index a", g3x3_constraint%a, &
    1202            2 :             "G3X3| Atom index b", g3x3_constraint%b, &
    1203            4 :             "G3X3| Atom index c", g3x3_constraint%c
    1204              :          WRITE (UNIT=iw, FMT="(T2,A,T66,F15.8)") &
    1205            2 :             "G3X3| Distance (a,b) [Angstrom]", cp_unit_from_cp2k(g3x3_constraint%dab, "Angstrom"), &
    1206            2 :             "G3X3| Distance (a,c) [Angstrom]", cp_unit_from_cp2k(g3x3_constraint%dac, "Angstrom"), &
    1207            4 :             "G3X3| Distance (b,c) [Angstrom]", cp_unit_from_cp2k(g3x3_constraint%dbc, "Angstrom")
    1208              :       END IF
    1209              : 
    1210            2 :    END SUBROUTINE write_g3x3_constraint
    1211              : 
    1212              : ! **************************************************************************************************
    1213              : !> \brief Write G4x6 constraint information to output unit
    1214              : !> \param g4x6_constraint Data set of the g4x6 constraint
    1215              : !> \param ig4x6 G4x6 constraint/restraint number (index)
    1216              : !> \param iw Logical unit number of the output unit
    1217              : !> \author Matthias Krack (26.11.2025)
    1218              : ! **************************************************************************************************
    1219            2 :    SUBROUTINE write_g4x6_constraint(g4x6_constraint, ig4x6, iw)
    1220              : 
    1221              :       TYPE(g4x6_constraint_type), INTENT(IN), POINTER    :: g4x6_constraint
    1222              :       INTEGER, INTENT(IN)                                :: ig4x6, iw
    1223              : 
    1224            2 :       IF (iw > 0) THEN
    1225            2 :          CPASSERT(ASSOCIATED(g4x6_constraint))
    1226            2 :          IF (g4x6_constraint%restraint%active) THEN
    1227              :             WRITE (UNIT=iw, FMT="(/,T2,A,T71,I10)") &
    1228            1 :                "G4X6| Number (restraint)", ig4x6
    1229              :             WRITE (UNIT=iw, FMT="(T2,A,T66,ES15.6)") &
    1230            1 :                "G4X6| Restraint constant k [a.u.]", g4x6_constraint%restraint%k0
    1231              :          ELSE
    1232              :             WRITE (UNIT=iw, FMT="(/,T2,A,T71,I10)") &
    1233            1 :                "G4X6| Number (constraint)", ig4x6
    1234              :          END IF
    1235              :          WRITE (UNIT=iw, FMT="(T2,A,T71,I10)") &
    1236            2 :             "G4X6| Atom index a", g4x6_constraint%a, &
    1237            2 :             "G4X6| Atom index b", g4x6_constraint%b, &
    1238            2 :             "G4X6| Atom index c", g4x6_constraint%c, &
    1239            4 :             "G4X6| Atom index c", g4x6_constraint%d
    1240              :          WRITE (UNIT=iw, FMT="(T2,A,T66,F15.8)") &
    1241            2 :             "G4X6| Distance (a,b) [Angstrom]", cp_unit_from_cp2k(g4x6_constraint%dab, "Angstrom"), &
    1242            2 :             "G4X6| Distance (a,c) [Angstrom]", cp_unit_from_cp2k(g4x6_constraint%dac, "Angstrom"), &
    1243            2 :             "G4X6| Distance (a,d) [Angstrom]", cp_unit_from_cp2k(g4x6_constraint%dad, "Angstrom"), &
    1244            2 :             "G4X6| Distance (b,c) [Angstrom]", cp_unit_from_cp2k(g4x6_constraint%dbc, "Angstrom"), &
    1245            2 :             "G4X6| Distance (b,d) [Angstrom]", cp_unit_from_cp2k(g4x6_constraint%dbd, "Angstrom"), &
    1246            4 :             "G4X6| Distance (c,d) [Angstrom]", cp_unit_from_cp2k(g4x6_constraint%dcd, "Angstrom")
    1247              :       END IF
    1248              : 
    1249            2 :    END SUBROUTINE write_g4x6_constraint
    1250              : 
    1251            0 : END MODULE molecule_kind_types
        

Generated by: LCOV version 2.0-1