LCOV - code coverage report
Current view: top level - src - input_cp2k_check.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:71c3ab0) Lines: 92.2 % 603 556
Test Date: 2026-07-25 06:35:44 Functions: 100.0 % 9 9

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief checks the input and perform some automatic "magic" on it
      10              : !> \par History
      11              : !>      01.2006 created [fawzi]
      12              : !> \author fawzi
      13              : ! **************************************************************************************************
      14              : MODULE input_cp2k_check
      15              :    USE cp_log_handling,                 ONLY: cp_to_string
      16              :    USE cp_parser_types,                 ONLY: cp_parser_type,&
      17              :                                               parser_create,&
      18              :                                               parser_release
      19              :    USE cp_units,                        ONLY: cp_unit_set_create,&
      20              :                                               cp_unit_set_release,&
      21              :                                               cp_unit_set_type
      22              :    USE input_constants,                 ONLY: &
      23              :         do_qs, do_region_global, do_thermo_al, do_thermo_csvr, do_thermo_gle, do_thermo_nose, &
      24              :         do_thermo_same_as_part, mimic_run, negf_run, npt_f_ensemble, npt_i_ensemble, &
      25              :         npt_ia_ensemble, vdw_nl_LMKLL, xc_funct_b3lyp, xc_funct_beefvdw, xc_funct_blyp, &
      26              :         xc_funct_bp, xc_funct_hcth120, xc_funct_no_shortcut, xc_funct_olyp, xc_funct_pade, &
      27              :         xc_funct_pbe, xc_funct_pbe0, xc_funct_tpss, xc_funct_xwpbe, xc_none, xc_vdw_fun_nonloc
      28              :    USE input_keyword_types,             ONLY: keyword_type
      29              :    USE input_parsing,                   ONLY: section_vals_parse
      30              :    USE input_section_types,             ONLY: &
      31              :         section_type, section_vals_create, section_vals_get, section_vals_get_subs_vals, &
      32              :         section_vals_get_subs_vals2, section_vals_get_subs_vals3, section_vals_release, &
      33              :         section_vals_remove_values, section_vals_set_subs_vals, section_vals_type, &
      34              :         section_vals_val_get, section_vals_val_set, section_vals_val_unset
      35              :    USE input_val_types,                 ONLY: logical_t
      36              :    USE kinds,                           ONLY: default_path_length,&
      37              :                                               default_string_length,&
      38              :                                               dp
      39              :    USE memory_utilities,                ONLY: reallocate
      40              :    USE message_passing,                 ONLY: mp_para_env_type
      41              :    USE xc_input_constants,              ONLY: do_vwn5
      42              : #include "./base/base_uses.f90"
      43              : 
      44              :    IMPLICIT NONE
      45              :    PRIVATE
      46              : 
      47              :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
      48              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_check'
      49              : 
      50              :    PUBLIC :: check_cp2k_input, xc_functionals_expand, remove_restart_info
      51              : 
      52              : CONTAINS
      53              : 
      54              : ! **************************************************************************************************
      55              : !> \brief performs further checks on an input that parsed successfully
      56              : !> \param input_declaration ...
      57              : !> \param input_file the parsed input
      58              : !> \param para_env ...
      59              : !> \param output_unit ...
      60              : !> \author fawzi
      61              : !> \note
      62              : !>      at the moment does nothing
      63              : ! **************************************************************************************************
      64        84668 :    SUBROUTINE check_cp2k_input(input_declaration, input_file, para_env, output_unit)
      65              :       TYPE(section_type), POINTER                        :: input_declaration
      66              :       TYPE(section_vals_type), POINTER                   :: input_file
      67              :       TYPE(mp_para_env_type), POINTER                    :: para_env
      68              :       INTEGER, INTENT(IN), OPTIONAL                      :: output_unit
      69              : 
      70              :       CHARACTER(len=*), PARAMETER                        :: routineN = 'check_cp2k_input'
      71              : 
      72              :       INTEGER                                            :: force_eval_method, handle, iforce_eval, &
      73              :                                                             nforce_eval, run_type
      74              :       LOGICAL                                            :: apply_ext_potential, do_center, &
      75              :                                                             explicit, explicit_embed, explicit_mix
      76              :       TYPE(section_vals_type), POINTER                   :: section, section1, section2, section3, &
      77              :                                                             section4, sections
      78              : 
      79        21167 :       CALL timeset(routineN, handle)
      80        21167 :       CPASSERT(ASSOCIATED(input_file))
      81        21167 :       CPASSERT(input_file%ref_count > 0)
      82              :       ! ext_restart
      83        21167 :       IF (PRESENT(output_unit)) THEN
      84        21167 :          CALL handle_ext_restart(input_declaration, input_file, para_env, output_unit)
      85              :       END IF
      86              : 
      87              :       ! checks on force_eval section
      88        21167 :       sections => section_vals_get_subs_vals(input_file, "FORCE_EVAL")
      89        21167 :       CALL section_vals_get(sections, n_repetition=nforce_eval)
      90              : 
      91              :       ! multiple force_eval only if present RESPA, or MIXED or EMBED calculation is performed
      92        21167 :       section2 => section_vals_get_subs_vals(input_file, "MOTION%MD%RESPA")
      93        21167 :       CALL section_vals_get(section2, explicit=explicit)
      94        41770 :       DO iforce_eval = 1, nforce_eval
      95              :          section3 => section_vals_get_subs_vals(sections, "MIXED", &
      96        20869 :                                                 i_rep_section=iforce_eval)
      97        20869 :          CALL section_vals_get(section3, explicit=explicit_mix)
      98        41770 :          IF (explicit_mix) EXIT
      99              :       END DO
     100        42384 :       DO iforce_eval = 1, nforce_eval
     101              :          section4 => section_vals_get_subs_vals(sections, "EMBED", &
     102        21265 :                                                 i_rep_section=iforce_eval)
     103        21265 :          CALL section_vals_get(section4, explicit=explicit_embed)
     104        42384 :          IF (explicit_embed) EXIT
     105              :       END DO
     106              :       ! also allow multiple force_eval for NEGF run
     107        21167 :       CALL section_vals_val_get(input_file, "GLOBAL%RUN_TYPE", i_val=run_type)
     108              : 
     109        21167 :       IF (((explicit .AND. (nforce_eval == 1)) .OR. (.NOT. explicit .AND. (nforce_eval > 1))) .AND. run_type /= negf_run) THEN
     110          314 :          IF ((explicit_mix .AND. (nforce_eval == 1)) .OR. (.NOT. explicit_mix .AND. (nforce_eval > 1))) THEN
     111           48 :             IF ((explicit_embed .AND. (nforce_eval == 1)) .OR. (.NOT. explicit_embed .AND. (nforce_eval > 1))) THEN
     112              :                CALL cp_abort(__LOCATION__, &
     113              :                              "Error multiple force_env without RESPA or MIXED or EMBED, or RESPA with one single "// &
     114            0 :                              "or MIXED with only two force_env section.")
     115              :             END IF
     116              :          END IF
     117              :       END IF
     118        42624 :       DO iforce_eval = 1, nforce_eval
     119        21457 :          section => section_vals_get_subs_vals3(sections, "DFT", i_rep_section=iforce_eval)
     120              :          ! xc: expand and fix default for tddfpt
     121        21457 :          section1 => section_vals_get_subs_vals(section, "XC")
     122        21457 :          section2 => section_vals_get_subs_vals(section, "XC%XC_FUNCTIONAL")
     123        21457 :          CALL xc_functionals_expand(section2, section1)
     124        21457 :          section1 => section_vals_get_subs_vals(section, "XAS_TDP%KERNEL")
     125        21457 :          section2 => section_vals_get_subs_vals(section, "XAS_TDP%KERNEL%XC_FUNCTIONAL")
     126        21457 :          CALL xc_functionals_expand(section2, section1)
     127        21457 :          section1 => section_vals_get_subs_vals(sections, "PROPERTIES%RIXS%XAS_TDP%KERNEL")
     128        21457 :          section2 => section_vals_get_subs_vals(sections, "PROPERTIES%RIXS%XAS_TDP%KERNEL%XC_FUNCTIONAL")
     129        21457 :          CALL xc_functionals_expand(section2, section1)
     130        21457 :          section1 => section_vals_get_subs_vals(section, "ACTIVE_SPACE%XC")
     131        21457 :          section2 => section_vals_get_subs_vals(section, "ACTIVE_SPACE%XC%XC_FUNCTIONAL")
     132        42624 :          CALL xc_functionals_expand(section2, section1)
     133              :       END DO
     134              : 
     135              :       ! additional checks for a MiMiC run
     136        21167 :       IF (run_type == mimic_run) THEN
     137              :          ! disable CENTER_COORDINATES
     138              :          CALL section_vals_val_get(sections, "SUBSYS%TOPOLOGY%CENTER_COORDINATES%_SECTION_PARAMETERS_", &
     139            0 :                                    l_val=do_center)
     140            0 :          IF (do_center) THEN
     141              :             CALL section_vals_val_set(sections, &
     142              :                                       "SUBSYS%TOPOLOGY%CENTER_COORDINATES%_SECTION_PARAMETERS_", &
     143            0 :                                       l_val=.FALSE.)
     144            0 :             CPWARN("Turning off CENTER_COORDINATES for a MiMiC run.")
     145              :          END IF
     146              : 
     147              :          ! do not allow the use of external potential
     148            0 :          section => section_vals_get_subs_vals(sections, "DFT%EXTERNAL_POTENTIAL")
     149            0 :          CALL section_vals_get(section, explicit=apply_ext_potential)
     150            0 :          IF (apply_ext_potential) THEN
     151            0 :             CPABORT("The EXTERNAL_POTENTIAL section is not allowed for the MiMiC runtype.")
     152              :          END IF
     153              : 
     154              :          ! force eval methods supported with MiMiC
     155            0 :          CALL section_vals_val_get(sections, "METHOD", i_val=force_eval_method)
     156            0 :          IF (force_eval_method /= do_qs) THEN
     157            0 :             CPABORT("At the moment, only Quickstep method is supported with MiMiC.")
     158              :          END IF
     159              :       END IF
     160              : 
     161        21167 :       CALL timestop(handle)
     162        21167 :    END SUBROUTINE check_cp2k_input
     163              : 
     164              : ! **************************************************************************************************
     165              : !> \brief expand a shortcutted functional section
     166              : !> \param functionals the functional section to expand
     167              : !> \param xc_section ...
     168              : !> \author fawzi
     169              : ! **************************************************************************************************
     170        88504 :    SUBROUTINE xc_functionals_expand(functionals, xc_section)
     171              :       TYPE(section_vals_type), POINTER                   :: functionals, xc_section
     172              : 
     173              :       CHARACTER(LEN=512)                                 :: wrn_msg
     174              :       INTEGER                                            :: ifun, nfun, shortcut
     175              :       TYPE(section_vals_type), POINTER                   :: xc_fun
     176              : 
     177              :       CALL section_vals_val_get(functionals, "_SECTION_PARAMETERS_", &
     178        88504 :                                 i_val=shortcut)
     179              : 
     180        88504 :       ifun = 0
     181        88504 :       nfun = 0
     182         9955 :       DO
     183        98459 :          ifun = ifun + 1
     184        98459 :          xc_fun => section_vals_get_subs_vals2(functionals, i_section=ifun)
     185        98459 :          IF (.NOT. ASSOCIATED(xc_fun)) EXIT
     186         9955 :          nfun = nfun + 1
     187              :       END DO
     188              : !
     189        88504 :       IF (shortcut /= xc_funct_no_shortcut .AND. shortcut /= xc_none .AND. nfun > 0) THEN
     190              :          WRITE (wrn_msg, '(A)') "User requested a shortcut while defining an explicit XC functional. "// &
     191          102 :             "This is not recommended as it could lead to spurious behaviour. Please check input parameters."
     192          102 :          CPWARN(wrn_msg)
     193              :       END IF
     194              : 
     195          334 :       SELECT CASE (shortcut)
     196              :       CASE (xc_funct_no_shortcut, xc_none)
     197              :          ! nothing to expand
     198              :       CASE (xc_funct_pbe0)
     199              :          CALL section_vals_val_set(functionals, "PBE%_SECTION_PARAMETERS_", &
     200          334 :                                    l_val=.TRUE.)
     201              :          CALL section_vals_val_set(functionals, "PBE%SCALE_X", &
     202          334 :                                    r_val=0.75_dp)
     203              :          CALL section_vals_val_set(functionals, "PBE%SCALE_C", &
     204          334 :                                    r_val=1.0_dp)
     205              :          ! Hartree Fock Exact Exchange
     206              :          CALL section_vals_val_set(xc_section, "HF%FRACTION", &
     207          334 :                                    r_val=0.25_dp)
     208              :          CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
     209          334 :                                    i_val=xc_funct_no_shortcut)
     210              :       CASE (xc_funct_beefvdw)
     211              :          CALL section_vals_val_set(functionals, "PBE%_SECTION_PARAMETERS_", & !40% PBEc
     212            2 :                                    l_val=.TRUE.)
     213              :          CALL section_vals_val_set(functionals, "PBE%SCALE_C", &
     214            2 :                                    r_val=0.3998335231_dp)
     215              :          CALL section_vals_val_set(functionals, "PBE%SCALE_X", & !no PBEx
     216            2 :                                    r_val=0.0000000000_dp)
     217              : 
     218              :          !PW92 correlation functional from libxc is required.
     219              :          !The cp2k-native PW92 gives disagreeing results (in the 0.01E_H
     220              :          !decimal) and yields inconsistent forces in a DEBUG run.
     221              :          !(rk, 6.3.2014)
     222              :          CALL section_vals_val_set(functionals, "LDA_C_PW%_SECTION_PARAMETERS_", & !60%LDA
     223            2 :                                    l_val=.TRUE.)
     224              :          CALL section_vals_val_set(functionals, "LDA_C_PW%SCALE", &
     225            2 :                                    r_val=0.6001664769_dp)
     226              : 
     227              :          CALL section_vals_val_set(functionals, "BEEF%_SECTION_PARAMETERS_", & !BEEF exchange
     228            2 :                                    l_val=.TRUE.)
     229              : 
     230              :          !NONLOCAL, LMKLL.
     231              :          CALL section_vals_val_set(xc_section, "VDW_POTENTIAL%DISPERSION_FUNCTIONAL", &
     232            2 :                                    i_val=xc_vdw_fun_nonloc)
     233              :          CALL section_vals_val_set(xc_section, "VDW_POTENTIAL%NON_LOCAL%TYPE", &
     234            2 :                                    i_val=vdw_nl_LMKLL)
     235              :          CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
     236            2 :                                    i_val=xc_funct_no_shortcut)
     237              :       CASE (xc_funct_b3lyp)
     238              :          CALL section_vals_val_set(functionals, "BECKE88%_SECTION_PARAMETERS_", &
     239           40 :                                    l_val=.TRUE.)
     240              :          CALL section_vals_val_set(functionals, "BECKE88%SCALE_X", &
     241           40 :                                    r_val=0.72_dp)
     242              :          CALL section_vals_val_set(functionals, "LYP%_SECTION_PARAMETERS_", &
     243           40 :                                    l_val=.TRUE.)
     244              :          CALL section_vals_val_set(functionals, "LYP%SCALE_C", &
     245           40 :                                    r_val=0.81_dp)
     246              :          CALL section_vals_val_set(functionals, "VWN%_SECTION_PARAMETERS_", &
     247           40 :                                    l_val=.TRUE.)
     248              :          CALL section_vals_val_set(functionals, "VWN%FUNCTIONAL_TYPE", &
     249           40 :                                    i_val=do_vwn5)
     250              :          CALL section_vals_val_set(functionals, "VWN%SCALE_C", &
     251           40 :                                    r_val=0.19_dp)
     252              :          CALL section_vals_val_set(functionals, "XALPHA%_SECTION_PARAMETERS_", &
     253           40 :                                    l_val=.TRUE.)
     254              :          CALL section_vals_val_set(functionals, "XALPHA%SCALE_X", &
     255           40 :                                    r_val=0.08_dp)
     256              :          ! Hartree Fock Exact Exchange
     257              :          CALL section_vals_val_set(xc_section, "HF%FRACTION", &
     258           40 :                                    r_val=0.20_dp)
     259              :          CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
     260           40 :                                    i_val=xc_funct_no_shortcut)
     261              :       CASE (xc_funct_blyp)
     262              :          CALL section_vals_val_set(functionals, "BECKE88%_SECTION_PARAMETERS_", &
     263          458 :                                    l_val=.TRUE.)
     264              :          CALL section_vals_val_set(functionals, "LYP%_SECTION_PARAMETERS_", &
     265          458 :                                    l_val=.TRUE.)
     266              :          CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
     267          458 :                                    i_val=xc_funct_no_shortcut)
     268              :       CASE (xc_funct_bp)
     269              :          CALL section_vals_val_set(functionals, "BECKE88%_SECTION_PARAMETERS_", &
     270           14 :                                    l_val=.TRUE.)
     271              :          CALL section_vals_val_set(functionals, "P86C%_SECTION_PARAMETERS_", &
     272           14 :                                    l_val=.TRUE.)
     273              :          CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
     274           14 :                                    i_val=xc_funct_no_shortcut)
     275              :       CASE (xc_funct_pade)
     276              :          CALL section_vals_val_set(functionals, "PADE%_SECTION_PARAMETERS_", &
     277         2183 :                                    l_val=.TRUE.)
     278              :          CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
     279         2183 :                                    i_val=xc_funct_no_shortcut)
     280              :       CASE (xc_funct_pbe)
     281              :          CALL section_vals_val_set(functionals, "PBE%_SECTION_PARAMETERS_", &
     282         2090 :                                    l_val=.TRUE.)
     283              :          CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
     284         2090 :                                    i_val=xc_funct_no_shortcut)
     285              :       CASE (xc_funct_xwpbe)
     286              :          CALL section_vals_val_set(functionals, "XWPBE%_SECTION_PARAMETERS_", &
     287            0 :                                    l_val=.TRUE.)
     288              :          CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
     289            0 :                                    i_val=xc_funct_no_shortcut)
     290              :       CASE (xc_funct_tpss)
     291              :          CALL section_vals_val_set(functionals, "TPSS%_SECTION_PARAMETERS_", &
     292           90 :                                    l_val=.TRUE.)
     293              :          CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
     294           90 :                                    i_val=xc_funct_no_shortcut)
     295              :       CASE (xc_funct_olyp)
     296              :          CALL section_vals_val_set(functionals, "OPTX%_SECTION_PARAMETERS_", &
     297            6 :                                    l_val=.TRUE.)
     298              :          CALL section_vals_val_set(functionals, "LYP%_SECTION_PARAMETERS_", &
     299            6 :                                    l_val=.TRUE.)
     300              :          CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
     301            6 :                                    i_val=xc_funct_no_shortcut)
     302              :       CASE (xc_funct_hcth120)
     303              :          CALL section_vals_val_set(functionals, "HCTH%_SECTION_PARAMETERS_", &
     304           14 :                                    l_val=.TRUE.)
     305              :          CALL section_vals_val_set(functionals, "HCTH%PARAMETER_SET", &
     306           14 :                                    i_val=120)
     307              :          CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
     308           14 :                                    i_val=xc_funct_no_shortcut)
     309              :       CASE default
     310        88504 :          CPABORT("unknown shortcut "//TRIM(ADJUSTL(cp_to_string(shortcut))))
     311              :       END SELECT
     312        88504 :    END SUBROUTINE xc_functionals_expand
     313              : 
     314              : ! **************************************************************************************************
     315              : !> \brief Replaces the requested sections in the input with those found
     316              : !>      in the external restart (EXT_RESTART%RESTART_FILE_NAME).
     317              : !> \param input_declaration ...
     318              : !> \param input_file the input file to initialize
     319              : !> \param para_env ...
     320              : !> \param output_unit ...
     321              : !> \author fawzi
     322              : ! **************************************************************************************************
     323        21167 :    SUBROUTINE handle_ext_restart(input_declaration, input_file, para_env, output_unit)
     324              :       TYPE(section_type), POINTER                        :: input_declaration
     325              :       TYPE(section_vals_type), POINTER                   :: input_file
     326              :       TYPE(mp_para_env_type), POINTER                    :: para_env
     327              :       INTEGER, INTENT(IN)                                :: output_unit
     328              : 
     329              :       CHARACTER(len=*), PARAMETER :: routineN = 'handle_ext_restart'
     330              : 
     331              :       CHARACTER(default_path_length)                     :: r_file_path
     332              :       INTEGER                                            :: handle
     333              :       TYPE(section_vals_type), POINTER                   :: r_section
     334              : 
     335        21167 :       CALL timeset(routineN, handle)
     336              :       ! Handle restart file
     337        21167 :       r_section => section_vals_get_subs_vals(input_file, "EXT_RESTART")
     338        21167 :       CALL section_vals_val_get(r_section, "RESTART_FILE_NAME", c_val=r_file_path)
     339              : 
     340        21167 :       IF (r_file_path /= " ") THEN
     341              :          BLOCK
     342              :             CHARACTER(default_path_length)                     :: binary_restart_file
     343              :             CHARACTER(default_string_length)                   :: path
     344              :             CHARACTER(LEN=default_string_length), &
     345          216 :                DIMENSION(:), POINTER                           :: restarted_infos
     346              :             INTEGER                                            :: ensemble, i_rep_val, &
     347              :                                                                   iforce_eval, myi, n_rep_val, &
     348              :                                                                   nforce_eval1, nforce_eval2
     349          216 :             INTEGER, DIMENSION(:), POINTER                     :: ivec, iwalkers_status, iwork, &
     350          216 :                                                                   rwalkers_status
     351              :             LOGICAL                                            :: bsse_check, check, explicit1, explicit2, &
     352              :                                                                   flag, flag2, qmmm_check, subsys_check
     353              :             REAL(KIND=dp)                                      :: myt
     354          216 :             REAL(KIND=dp), DIMENSION(:), POINTER               :: vec, work
     355              :             TYPE(section_vals_type), POINTER                   :: rep_sections, restart_file, &
     356              :                                                                   section, section1, section2, &
     357              :                                                                   sections1, sections2
     358              : 
     359          216 :             NULLIFY (restarted_infos, iwalkers_status, rwalkers_status, vec, ivec, work, iwork)
     360          216 :             CALL section_vals_val_get(r_section, "BINARY_RESTART_FILE_NAME", c_val=binary_restart_file)
     361              : 
     362              :             BLOCK
     363              :                TYPE(cp_parser_type)                      :: cpparser
     364              :                TYPE(cp_unit_set_type)                   :: default_units
     365              :                ! parse the input
     366          216 :                NULLIFY (restart_file)
     367          216 :                CALL section_vals_create(restart_file, input_declaration)
     368          216 :                CALL parser_create(cpparser, file_name=r_file_path, para_env=para_env)
     369          216 :                CALL cp_unit_set_create(default_units, "OUTPUT")
     370              :                CALL section_vals_parse(restart_file, cpparser, root_section=.FALSE., &
     371          216 :                                        default_units=default_units)
     372          216 :                CALL cp_unit_set_release(default_units)
     373         3240 :                CALL parser_release(cpparser)
     374              :             END BLOCK
     375              : 
     376              :             ! Restart and input files same number of force_env sections
     377          216 :             sections1 => section_vals_get_subs_vals(restart_file, "FORCE_EVAL")
     378          216 :             CALL section_vals_get(sections1, n_repetition=nforce_eval1)
     379          216 :             sections2 => section_vals_get_subs_vals(input_file, "FORCE_EVAL")
     380          216 :             CALL section_vals_get(sections2, n_repetition=nforce_eval2)
     381          216 :             IF (nforce_eval1 /= nforce_eval2) THEN
     382            0 :                CPABORT("Restart and input file MUST have the number of force_env sections")
     383              :             END IF
     384              :             ! Handle default restarts
     385          216 :             CALL handle_defaults_restart(r_section)
     386              : 
     387              :             ! Real restart of force_evals
     388          448 :             DO iforce_eval = 1, nforce_eval1
     389              :                section1 => section_vals_get_subs_vals3(sections1, "SUBSYS", &
     390          232 :                                                        i_rep_section=iforce_eval)
     391              :                section2 => section_vals_get_subs_vals3(sections2, "SUBSYS", &
     392          232 :                                                        i_rep_section=iforce_eval)
     393              :                ! Some care needs to be handled when treating multiple force_eval
     394              :                ! Both subsys need to be consistently associated or not
     395              :                ! Mixed stuff will be rejected for safety reason..
     396          232 :                subsys_check = (ASSOCIATED(section1) .EQV. ASSOCIATED(section2))
     397          232 :                IF (subsys_check) THEN
     398          232 :                   IF (ASSOCIATED(section1)) THEN
     399          232 :                      CALL section_vals_val_get(r_section, "RESTART_CELL", l_val=flag)
     400          232 :                      IF (flag) THEN
     401          210 :                         section => section_vals_get_subs_vals(section1, "CELL")
     402          210 :                         CALL section_vals_set_subs_vals(section2, "CELL", section)
     403          210 :                         CALL set_restart_info("CELL", restarted_infos)
     404              :                      END IF
     405              : 
     406          232 :                      CALL section_vals_val_get(r_section, "RESTART_POS", l_val=flag)
     407          232 :                      IF (flag) THEN
     408          220 :                         section => section_vals_get_subs_vals(section1, "COORD")
     409          220 :                         CALL section_vals_set_subs_vals(section2, "COORD", section)
     410          220 :                         CALL set_restart_info("COORDINATES", restarted_infos)
     411              :                         ! Copy over also the information on the multiple_unit_cell
     412          220 :                         CALL section_vals_val_get(section1, "TOPOLOGY%MULTIPLE_UNIT_CELL", i_vals=ivec)
     413          220 :                         ALLOCATE (iwork(3))
     414         1540 :                         iwork = ivec
     415          220 :                         CALL section_vals_val_set(section2, "TOPOLOGY%MULTIPLE_UNIT_CELL", i_vals_ptr=iwork)
     416              :                      END IF
     417              : 
     418          232 :                      CALL section_vals_val_get(r_section, "RESTART_RANDOMG", l_val=flag)
     419          232 :                      IF (flag) THEN
     420          200 :                         section => section_vals_get_subs_vals(section1, "RNG_INIT")
     421          200 :                         CALL section_vals_set_subs_vals(section2, "RNG_INIT", section)
     422          200 :                         CALL set_restart_info("RANDOM NUMBER GENERATOR", restarted_infos)
     423              :                      END IF
     424              : 
     425          232 :                      CALL section_vals_val_get(r_section, "RESTART_VEL", l_val=flag)
     426          232 :                      IF (flag) THEN
     427          214 :                         section => section_vals_get_subs_vals(section1, "VELOCITY")
     428          214 :                         CALL section_vals_set_subs_vals(section2, "VELOCITY", section)
     429          214 :                         CALL set_restart_info("VELOCITIES", restarted_infos)
     430              :                      END IF
     431              : 
     432              :                      ! Core-Shell information "restarted" only when strictly necessary
     433          232 :                      CALL section_vals_val_get(r_section, "RESTART_SHELL_POS", l_val=flag)
     434          232 :                      IF (flag) THEN
     435          220 :                         section => section_vals_get_subs_vals(section1, "SHELL_COORD")
     436          220 :                         CALL section_vals_set_subs_vals(section2, "SHELL_COORD", section)
     437          220 :                         IF (check_restart(section1, section2, "SHELL_COORD")) THEN
     438           32 :                            CALL set_restart_info("SHELL COORDINATES", restarted_infos)
     439              :                         END IF
     440              :                      END IF
     441          232 :                      CALL section_vals_val_get(r_section, "RESTART_CORE_POS", l_val=flag)
     442          232 :                      IF (flag) THEN
     443          220 :                         section => section_vals_get_subs_vals(section1, "CORE_COORD")
     444          220 :                         CALL section_vals_set_subs_vals(section2, "CORE_COORD", section)
     445          220 :                         IF (check_restart(section1, section2, "CORE_COORD")) THEN
     446           32 :                            CALL set_restart_info("CORE COORDINATES", restarted_infos)
     447              :                         END IF
     448              :                      END IF
     449          232 :                      CALL section_vals_val_get(r_section, "RESTART_SHELL_VELOCITY", l_val=flag)
     450          232 :                      IF (flag) THEN
     451          220 :                         section => section_vals_get_subs_vals(section1, "SHELL_VELOCITY")
     452          220 :                         CALL section_vals_set_subs_vals(section2, "SHELL_VELOCITY", section)
     453          220 :                         IF (check_restart(section1, section2, "SHELL_VELOCITY")) THEN
     454           24 :                            CALL set_restart_info("SHELL VELOCITIES", restarted_infos)
     455              :                         END IF
     456              :                      END IF
     457          232 :                      CALL section_vals_val_get(r_section, "RESTART_CORE_VELOCITY", l_val=flag)
     458          232 :                      IF (flag) THEN
     459          220 :                         section => section_vals_get_subs_vals(section1, "CORE_VELOCITY")
     460          220 :                         CALL section_vals_set_subs_vals(section2, "CORE_VELOCITY", section)
     461          220 :                         IF (check_restart(section1, section2, "CORE_VELOCITY")) THEN
     462           24 :                            CALL set_restart_info("CORE VELOCITIES", restarted_infos)
     463              :                         END IF
     464              :                      END IF
     465              :                   END IF
     466              :                ELSE
     467              :                   CALL cp_abort(__LOCATION__, &
     468              :                                 "Error while reading the restart file. Two force_eval have incompatible"// &
     469              :                                 " subsys.One of them has an allocated subsys while the other has not! Check your"// &
     470            0 :                                 " input file or whether the restart file is compatible with the input!")
     471              :                END IF
     472              :                ! QMMM restarts
     473          232 :                CALL section_vals_val_get(r_section, "RESTART_QMMM", l_val=flag)
     474          232 :                section1 => section_vals_get_subs_vals3(sections1, "QMMM", i_rep_section=iforce_eval)
     475          232 :                section2 => section_vals_get_subs_vals3(sections2, "QMMM", i_rep_section=iforce_eval)
     476          232 :                CALL section_vals_get(section1, explicit=explicit1)
     477          232 :                CALL section_vals_get(section2, explicit=explicit2)
     478          232 :                qmmm_check = (explicit1 .AND. explicit2)
     479          232 :                IF (flag .AND. qmmm_check) THEN
     480            0 :                   CALL set_restart_info("QMMM TRANSLATION VECTOR", restarted_infos)
     481            0 :                   CALL section_vals_val_get(section1, "INITIAL_TRANSLATION_VECTOR", r_vals=vec)
     482            0 :                   ALLOCATE (work(3))
     483            0 :                   work = vec
     484            0 :                   CALL section_vals_val_set(section2, "INITIAL_TRANSLATION_VECTOR", r_vals_ptr=work)
     485              :                END IF
     486              :                ! BSSE restarts
     487          232 :                CALL section_vals_val_get(r_section, "RESTART_BSSE", l_val=flag)
     488          232 :                section1 => section_vals_get_subs_vals3(sections1, "BSSE", i_rep_section=iforce_eval)
     489          232 :                section2 => section_vals_get_subs_vals3(sections2, "BSSE", i_rep_section=iforce_eval)
     490          232 :                CALL section_vals_get(section1, explicit=explicit1)
     491          232 :                CALL section_vals_get(section2, explicit=explicit2)
     492          232 :                bsse_check = (explicit1 .AND. explicit2)
     493         1376 :                IF (flag .AND. bsse_check) THEN
     494            2 :                   section => section_vals_get_subs_vals(section1, "FRAGMENT_ENERGIES")
     495            2 :                   CALL section_vals_set_subs_vals(section2, "FRAGMENT_ENERGIES", section)
     496            2 :                   CALL set_restart_info("BSSE FRAGMENT ENERGIES", restarted_infos)
     497              :                END IF
     498              :             END DO
     499              : 
     500          216 :             CALL section_vals_val_get(r_section, "RESTART_COUNTERS", l_val=flag)
     501          216 :             IF (flag) THEN
     502          208 :                IF (check_restart(input_file, restart_file, "MOTION%MD")) THEN
     503          168 :                   CALL section_vals_val_get(restart_file, "MOTION%MD%STEP_START_VAL", i_val=myi)
     504          168 :                   CALL section_vals_val_set(input_file, "MOTION%MD%STEP_START_VAL", i_val=myi)
     505          168 :                   CALL section_vals_val_get(restart_file, "MOTION%MD%TIME_START_VAL", r_val=myt)
     506          168 :                   CALL section_vals_val_set(input_file, "MOTION%MD%TIME_START_VAL", r_val=myt)
     507          168 :                   CALL section_vals_val_get(restart_file, "MOTION%MD%ECONS_START_VAL", r_val=myt)
     508          168 :                   CALL section_vals_val_set(input_file, "MOTION%MD%ECONS_START_VAL", r_val=myt)
     509          168 :                   CALL set_restart_info("MD COUNTERS", restarted_infos)
     510              :                END IF
     511              :                !
     512          208 :                IF (check_restart(input_file, restart_file, "MOTION%GEO_OPT")) THEN
     513              :                   ! GEO_OPT
     514           18 :                   CALL section_vals_val_get(restart_file, "MOTION%GEO_OPT%STEP_START_VAL", i_val=myi)
     515           18 :                   CALL section_vals_val_set(input_file, "MOTION%GEO_OPT%STEP_START_VAL", i_val=myi)
     516           18 :                   CALL set_restart_info("GEO_OPT COUNTERS", restarted_infos)
     517              :                   ! ROT_OPT
     518           18 :                   IF (check_restart(input_file, restart_file, "MOTION%GEO_OPT%TRANSITION_STATE%DIMER%ROT_OPT")) THEN
     519              :                      CALL section_vals_val_get(restart_file, "MOTION%GEO_OPT%TRANSITION_STATE%DIMER%ROT_OPT%STEP_START_VAL", &
     520            2 :                                                i_val=myi)
     521              :                      CALL section_vals_val_set(input_file, "MOTION%GEO_OPT%TRANSITION_STATE%DIMER%ROT_OPT%STEP_START_VAL", &
     522            2 :                                                i_val=myi)
     523            2 :                      CALL set_restart_info("ROT_OPT COUNTERS", restarted_infos)
     524              :                   END IF
     525              :                END IF
     526              :                !
     527          208 :                IF (check_restart(input_file, restart_file, "MOTION%GEO_OPT")) THEN
     528              :                   ! CELL_OPT
     529           18 :                   CALL section_vals_val_get(restart_file, "MOTION%CELL_OPT%STEP_START_VAL", i_val=myi)
     530           18 :                   CALL section_vals_val_set(input_file, "MOTION%CELL_OPT%STEP_START_VAL", i_val=myi)
     531           18 :                   CALL set_restart_info("CELL_OPT COUNTERS", restarted_infos)
     532              :                END IF
     533              :                !
     534          208 :                IF (check_restart(input_file, restart_file, "OPTIMIZE_INPUT")) THEN
     535            2 :                   CALL section_vals_val_get(restart_file, "OPTIMIZE_INPUT%ITER_START_VAL", i_val=myi)
     536            2 :                   CALL section_vals_val_set(input_file, "OPTIMIZE_INPUT%ITER_START_VAL", i_val=myi)
     537            2 :                   CALL set_restart_info("OPTIMIZE_INPUT ITERATION NUMBER", restarted_infos)
     538              :                END IF
     539              :                !
     540          208 :                IF (check_restart(input_file, restart_file, "MOTION%PINT")) THEN
     541              :                   ! PINT
     542           10 :                   CALL section_vals_val_get(restart_file, "MOTION%PINT%ITERATION", i_val=myi)
     543           10 :                   CALL section_vals_val_set(input_file, "MOTION%PINT%ITERATION", i_val=myi)
     544           10 :                   CALL set_restart_info("PINT ITERATION NUMBER", restarted_infos)
     545              :                END IF
     546              :                !
     547          208 :                CALL section_vals_val_get(r_section, "RESTART_METADYNAMICS", l_val=flag2)
     548          208 :                IF (flag2 .AND. check_restart(input_file, restart_file, "MOTION%FREE_ENERGY%METADYN")) THEN
     549              :                   CALL section_vals_val_get(restart_file, &
     550           12 :                                             "MOTION%FREE_ENERGY%METADYN%STEP_START_VAL", i_val=myi)
     551              :                   CALL section_vals_val_set(input_file, &
     552           12 :                                             "MOTION%FREE_ENERGY%METADYN%STEP_START_VAL", i_val=myi)
     553              :                   CALL section_vals_val_get(restart_file, &
     554           12 :                                             "MOTION%FREE_ENERGY%METADYN%NHILLS_START_VAL", i_val=myi)
     555              :                   CALL section_vals_val_set(input_file, &
     556           12 :                                             "MOTION%FREE_ENERGY%METADYN%NHILLS_START_VAL", i_val=myi)
     557              :                   !RG Adaptive hills
     558              :                   CALL section_vals_val_get(restart_file, &
     559           12 :                                             "MOTION%FREE_ENERGY%METADYN%OLD_HILL_NUMBER", i_val=myi)
     560              :                   CALL section_vals_val_set(input_file, &
     561           12 :                                             "MOTION%FREE_ENERGY%METADYN%OLD_HILL_NUMBER", i_val=myi)
     562              :                   CALL section_vals_val_get(restart_file, &
     563           12 :                                             "MOTION%FREE_ENERGY%METADYN%OLD_HILL_STEP", i_val=myi)
     564              :                   CALL section_vals_val_set(input_file, &
     565           12 :                                             "MOTION%FREE_ENERGY%METADYN%OLD_HILL_STEP", i_val=myi)
     566              :                   !RG Adaptive hills
     567           12 :                   CALL set_restart_info("METADYNAMIC COUNTERS", restarted_infos)
     568              :                END IF
     569              :             END IF
     570              : 
     571          216 :             CALL section_vals_val_get(r_section, "RESTART_AVERAGES", l_val=flag)
     572          216 :             IF (flag) THEN
     573          204 :                IF (check_restart(input_file, restart_file, "MOTION%MD")) THEN
     574          174 :                   rep_sections => section_vals_get_subs_vals(restart_file, "MOTION%MD%AVERAGES%RESTART_AVERAGES")
     575          174 :                   CALL section_vals_set_subs_vals(input_file, "MOTION%MD%AVERAGES%RESTART_AVERAGES", rep_sections)
     576          174 :                   CALL set_restart_info("MD AVERAGES", restarted_infos)
     577              :                END IF
     578              :             END IF
     579              : 
     580          216 :             CALL section_vals_val_get(r_section, "RESTART_BAND", l_val=flag)
     581          216 :             IF (flag .AND. check_restart(input_file, restart_file, "MOTION%BAND")) THEN
     582            6 :                rep_sections => section_vals_get_subs_vals(restart_file, "MOTION%BAND%REPLICA")
     583            6 :                CALL section_vals_set_subs_vals(input_file, "MOTION%BAND%REPLICA", rep_sections)
     584            6 :                CALL set_restart_info("BAND CALCULATION", restarted_infos)
     585              :             END IF
     586              : 
     587          216 :             CALL section_vals_val_get(r_section, "RESTART_OPTIMIZE_INPUT_VARIABLES", l_val=flag)
     588          216 :             IF (flag .AND. check_restart(input_file, restart_file, "OPTIMIZE_INPUT%VARIABLE")) THEN
     589            2 :                rep_sections => section_vals_get_subs_vals(restart_file, "OPTIMIZE_INPUT%VARIABLE")
     590            2 :                CALL section_vals_set_subs_vals(input_file, "OPTIMIZE_INPUT%VARIABLE", rep_sections)
     591            2 :                CALL set_restart_info("OPTIMIZE_INPUT: VARIABLES", restarted_infos)
     592              :             END IF
     593              : 
     594          216 :             CALL section_vals_val_get(r_section, "RESTART_BAROSTAT", l_val=flag)
     595          216 :             IF (flag .AND. check_restart(input_file, restart_file, "MOTION%MD%BAROSTAT")) THEN
     596              :                section => section_vals_get_subs_vals(restart_file, &
     597           22 :                                                      "MOTION%MD%BAROSTAT%MASS")
     598              :                CALL section_vals_set_subs_vals(input_file, "MOTION%MD%BAROSTAT%MASS", &
     599           22 :                                                section)
     600              :                section => section_vals_get_subs_vals(restart_file, &
     601           22 :                                                      "MOTION%MD%BAROSTAT%VELOCITY")
     602              :                CALL section_vals_set_subs_vals(input_file, "MOTION%MD%BAROSTAT%VELOCITY", &
     603           22 :                                                section)
     604           22 :                CALL set_restart_info("BAROSTAT", restarted_infos)
     605              :             END IF
     606              : 
     607          216 :             flag = check_restart(input_file, restart_file, "MOTION%MD")
     608          216 :             IF (flag) THEN
     609          176 :                CALL section_vals_val_get(input_file, "MOTION%MD%ENSEMBLE", i_val=ensemble)
     610          176 :                IF (ensemble == npt_i_ensemble .OR. ensemble == npt_f_ensemble .OR. ensemble == npt_ia_ensemble) THEN
     611           32 :                   CALL section_vals_val_get(r_section, "RESTART_BAROSTAT_THERMOSTAT", l_val=flag)
     612           32 :                   check = check_restart(input_file, restart_file, "MOTION%MD%BAROSTAT")
     613              :                   CALL restart_thermostat(flag, input_file, restart_file, "MOTION%MD%BAROSTAT%THERMOSTAT", &
     614           32 :                                           check=check)
     615           32 :                   IF (flag .AND. check) CALL set_restart_info("THERMOSTAT OF BAROSTAT", restarted_infos)
     616              :                END IF
     617              :             END IF
     618              : 
     619          216 :             check = check_restart(input_file, restart_file, "MOTION%MD%SHELL")
     620          216 :             IF (check) THEN
     621           18 :                CALL section_vals_val_get(r_section, "RESTART_SHELL_THERMOSTAT", l_val=flag)
     622           18 :                CALL restart_thermostat(flag, input_file, restart_file, "MOTION%MD%SHELL%THERMOSTAT")
     623           18 :                CALL set_restart_info("SHELL THERMOSTAT", restarted_infos)
     624              :             END IF
     625              : 
     626          216 :             CALL section_vals_val_get(r_section, "RESTART_THERMOSTAT", l_val=flag)
     627          216 :             CALL restart_thermostat(flag, input_file, restart_file, "MOTION%MD%THERMOSTAT")
     628          216 :             IF (flag) CALL set_restart_info("PARTICLE THERMOSTAT", restarted_infos)
     629              : 
     630          216 :             CALL section_vals_val_get(r_section, "RESTART_CONSTRAINT", l_val=flag)
     631          216 :             IF (flag .AND. check_restart(input_file, restart_file, "MOTION%CONSTRAINT")) THEN
     632           38 :                section => section_vals_get_subs_vals(restart_file, "MOTION%CONSTRAINT")
     633           38 :                CALL section_vals_set_subs_vals(input_file, "MOTION%CONSTRAINT", section)
     634           38 :                CALL set_restart_info("CONSTRAINTS/RESTRAINTS", restarted_infos)
     635              :             END IF
     636              : 
     637          216 :             CALL section_vals_val_get(r_section, "RESTART_METADYNAMICS", l_val=flag)
     638          216 :             IF (flag .AND. check_restart(input_file, restart_file, "MOTION%FREE_ENERGY%METADYN")) THEN
     639              :                section => section_vals_get_subs_vals(restart_file, &
     640           12 :                                                      "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_POS")
     641              :                CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_POS", &
     642           12 :                                                section)
     643              :                section => section_vals_get_subs_vals(restart_file, &
     644           12 :                                                      "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_SCALE")
     645              :                CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_SCALE", &
     646           12 :                                                section)
     647              :                section => section_vals_get_subs_vals(restart_file, &
     648           12 :                                                      "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_HEIGHT")
     649              :                CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_HEIGHT", &
     650           12 :                                                section)
     651              :                section => section_vals_get_subs_vals(restart_file, &
     652           12 :                                                      "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_INVDT")
     653              :                CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_INVDT", &
     654           12 :                                                section)
     655              :                ! Extended Lagrangian
     656              :                section => section_vals_get_subs_vals(restart_file, &
     657           12 :                                                      "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_SS0")
     658              :                CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_SS0", &
     659           12 :                                                section)
     660              :                section => section_vals_get_subs_vals(restart_file, &
     661           12 :                                                      "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_VVP")
     662              :                CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_VVP", &
     663           12 :                                                section)
     664              :                section => section_vals_get_subs_vals(restart_file, &
     665           12 :                                                      "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_SS")
     666              :                CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_SS", &
     667           12 :                                                section)
     668              :                section => section_vals_get_subs_vals(restart_file, &
     669           12 :                                                      "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_FS")
     670              :                CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_FS", &
     671           12 :                                                section)
     672           12 :                CALL set_restart_info("METADYNAMICS", restarted_infos)
     673              :             END IF
     674              : 
     675          216 :             CALL section_vals_val_get(r_section, "RESTART_TEMPERATURE_ANNEALING", l_val=flag)
     676          216 :             IF (flag .AND. check_restart(input_file, restart_file, "MOTION%MD")) THEN
     677            2 :                CALL section_vals_val_get(input_file, "MOTION%MD%TEMPERATURE_ANNEALING", r_val=myt, explicit=explicit1)
     678            2 :                IF ((.NOT. explicit1) .OR. (ABS(1._dp - myt) <= 1.E-10_dp)) THEN
     679              :                   CALL cp_warn(__LOCATION__, &
     680              :                                "I'm about to override the input temperature "// &
     681              :                                "with the temperature found in external restart "// &
     682            0 :                                "but TEMPERATURE_ANNEALING isn't explicitly given or it is set to 1.")
     683              :                END IF
     684            2 :                CALL section_vals_val_get(restart_file, "MOTION%MD%TEMPERATURE", r_val=myt, explicit=explicit1)
     685            2 :                IF (explicit1) THEN
     686            2 :                   CALL section_vals_val_get(input_file, "MOTION%MD%TEMPERATURE", r_val=myt)
     687              :                ELSE
     688              :                   CALL cp_warn(__LOCATION__, &
     689              :                                "I'm not going to override the input temperature "// &
     690            0 :                                "since the temperature isn't explicitly given in the external restart.")
     691              :                END IF
     692              :             END IF
     693              : 
     694          216 :             CALL section_vals_val_get(r_section, "RESTART_WALKERS", l_val=flag)
     695          216 :             IF (flag .AND. check_restart(input_file, restart_file, "MOTION%FREE_ENERGY%METADYN%MULTIPLE_WALKERS")) THEN
     696              :                CALL section_vals_val_get(restart_file, "MOTION%FREE_ENERGY%METADYN%MULTIPLE_WALKERS%WALKERS_STATUS", &
     697            4 :                                          i_vals=rwalkers_status)
     698           12 :                ALLOCATE (iwalkers_status(SIZE(rwalkers_status)))
     699           20 :                iwalkers_status = rwalkers_status
     700              :                CALL section_vals_val_set(input_file, "MOTION%FREE_ENERGY%METADYN%MULTIPLE_WALKERS%WALKERS_STATUS", &
     701            4 :                                          i_vals_ptr=iwalkers_status)
     702            4 :                CALL set_restart_info("WALKERS INFO", restarted_infos)
     703              :             END IF
     704              : 
     705          216 :             CALL section_vals_val_get(r_section, "RESTART_DIMER", l_val=flag)
     706          216 :             IF (flag .AND. check_restart(input_file, restart_file, "MOTION%GEO_OPT%TRANSITION_STATE%DIMER")) THEN
     707              :                section => section_vals_get_subs_vals(restart_file, &
     708            2 :                                                      "MOTION%GEO_OPT%TRANSITION_STATE%DIMER%DIMER_VECTOR")
     709              :                CALL section_vals_set_subs_vals(input_file, "MOTION%GEO_OPT%TRANSITION_STATE%DIMER%DIMER_VECTOR", &
     710            2 :                                                section)
     711            2 :                CALL set_restart_info("DIMER TRANSITION STATE SEARCH", restarted_infos)
     712              :             END IF
     713              : 
     714          216 :             CALL section_vals_val_get(r_section, "CUSTOM_PATH", n_rep_val=n_rep_val)
     715          216 :             DO i_rep_val = 1, n_rep_val
     716            0 :                CALL section_vals_val_get(r_section, "CUSTOM_PATH", i_rep_val=i_rep_val, c_val=path)
     717          216 :                IF (path /= " ") THEN
     718            0 :                   section => section_vals_get_subs_vals(restart_file, path)
     719            0 :                   CALL section_vals_set_subs_vals(input_file, path, section)
     720            0 :                   CALL set_restart_info("USER RESTART: "//TRIM(path), restarted_infos)
     721              :                END IF
     722              :             END DO
     723              : 
     724          216 :             CALL section_vals_val_get(r_section, "RESTART_RTP", l_val=flag)
     725              :             !          IF(flag.AND.check_restart(input_file, restart_file, "FORCE_EVAL%DFT%REAL_TIME_PROPAGATION")) THEN
     726          216 :             IF (flag) THEN
     727              :                section => section_vals_get_subs_vals(restart_file, &
     728          204 :                                                      "FORCE_EVAL%DFT%REAL_TIME_PROPAGATION")
     729          204 :                CALL section_vals_val_get(section, "INITIAL_WFN", i_val=myi)
     730              :                CALL section_vals_val_set(input_file, "FORCE_EVAL%DFT%REAL_TIME_PROPAGATION%INITIAL_WFN", &
     731          204 :                                          i_val=myi)
     732          204 :                CALL set_restart_info("REAL TIME PROPAGATION", restarted_infos)
     733              :             END IF
     734              : 
     735              :             ! PIMD
     736          216 :             CALL section_vals_val_get(r_section, "RESTART_PINT_POS", l_val=flag)
     737          216 :             IF (flag) THEN
     738          210 :                section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%BEADS%COORD")
     739          210 :                CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%BEADS%COORD", section)
     740          210 :                CALL set_restart_info("PINT BEAD POSITIONS", restarted_infos)
     741              :             END IF
     742          216 :             CALL section_vals_val_get(r_section, "RESTART_PINT_VEL", l_val=flag)
     743          216 :             IF (flag) THEN
     744          210 :                section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%BEADS%VELOCITY")
     745          210 :                CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%BEADS%VELOCITY", section)
     746          210 :                CALL set_restart_info("PINT BEAD VELOCITIES", restarted_infos)
     747              :             END IF
     748          216 :             CALL section_vals_val_get(r_section, "RESTART_PINT_NOSE", l_val=flag)
     749          216 :             IF (flag) THEN
     750          210 :                section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%NOSE%COORD")
     751          210 :                CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%NOSE%COORD", section)
     752          210 :                section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%NOSE%VELOCITY")
     753          210 :                CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%NOSE%VELOCITY", section)
     754          210 :                CALL set_restart_info("PINT NOSE THERMOSTAT", restarted_infos)
     755              :             END IF
     756          216 :             CALL section_vals_val_get(r_section, "RESTART_PINT_GLE", l_val=flag)
     757          216 :             IF (flag) THEN
     758          204 :                section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%GLE")
     759          204 :                CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%GLE", section)
     760          204 :                CALL set_restart_info("PINT GLE THERMOSTAT", restarted_infos)
     761              :             END IF
     762              : 
     763              :             ! PIMC
     764              :             !
     765          216 :             CALL section_vals_val_get(r_section, "RESTART_HELIUM_POS", l_val=flag)
     766          216 :             IF (flag) THEN
     767              :                CALL section_vals_val_get(input_file, "MOTION%PINT%HELIUM%NUM_ENV", &
     768          210 :                                          explicit=explicit1)
     769          210 :                IF (.NOT. explicit1) THEN
     770          204 :                   CALL section_vals_val_get(restart_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
     771          204 :                   CALL section_vals_val_set(input_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
     772              :                END IF
     773          210 :                section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%HELIUM%COORD")
     774          210 :                CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%HELIUM%COORD", section)
     775          210 :                CALL set_restart_info("HELIUM BEAD POSITIONS", restarted_infos)
     776              :             END IF
     777              :             !
     778          216 :             CALL section_vals_val_get(r_section, "RESTART_HELIUM_PERMUTATION", l_val=flag)
     779          216 :             IF (flag) THEN
     780              :                CALL section_vals_val_get(input_file, "MOTION%PINT%HELIUM%NUM_ENV", &
     781          210 :                                          explicit=explicit1)
     782          210 :                IF (.NOT. explicit1) THEN
     783            0 :                   CALL section_vals_val_get(restart_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
     784            0 :                   CALL section_vals_val_set(input_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
     785              :                END IF
     786          210 :                section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%HELIUM%PERM")
     787          210 :                CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%HELIUM%PERM", section)
     788          210 :                CALL set_restart_info("HELIUM PERMUTATION STATE", restarted_infos)
     789              :             END IF
     790              :             !
     791          216 :             CALL section_vals_val_get(r_section, "RESTART_HELIUM_FORCE", l_val=flag)
     792          216 :             IF (flag) THEN
     793              :                CALL section_vals_val_get(input_file, "MOTION%PINT%HELIUM%NUM_ENV", &
     794          206 :                                          explicit=explicit1)
     795          206 :                IF (.NOT. explicit1) THEN
     796            0 :                   CALL section_vals_val_get(restart_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
     797            0 :                   CALL section_vals_val_set(input_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
     798              :                END IF
     799          206 :                section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%HELIUM%FORCE")
     800          206 :                CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%HELIUM%FORCE", section)
     801          206 :                CALL set_restart_info("HELIUM FORCES ON SOLUTE", restarted_infos)
     802              :             END IF
     803              :             !
     804          216 :             CALL section_vals_val_get(r_section, "RESTART_HELIUM_RNG", l_val=flag)
     805          216 :             IF (flag) THEN
     806              :                CALL section_vals_val_get(input_file, "MOTION%PINT%HELIUM%NUM_ENV", &
     807          210 :                                          explicit=explicit1)
     808          210 :                IF (.NOT. explicit1) THEN
     809            0 :                   CALL section_vals_val_get(restart_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
     810            0 :                   CALL section_vals_val_set(input_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
     811              :                END IF
     812          210 :                section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%HELIUM%RNG_STATE")
     813          210 :                CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%HELIUM%RNG_STATE", section)
     814          210 :                CALL set_restart_info("HELIUM RNG STATE", restarted_infos)
     815              :             END IF
     816              :             !
     817              :             !
     818          216 :             CALL section_vals_val_get(r_section, "RESTART_HELIUM_DENSITIES", l_val=flag)
     819          216 :             IF (flag) THEN
     820              :                CALL section_vals_val_get(input_file, "MOTION%PINT%HELIUM%NUM_ENV", &
     821            0 :                                          explicit=explicit1)
     822            0 :                IF (.NOT. explicit1) THEN
     823            0 :                   CALL section_vals_val_get(restart_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
     824            0 :                   CALL section_vals_val_set(input_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
     825              :                END IF
     826            0 :                section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%HELIUM%RHO")
     827            0 :                CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%HELIUM%RHO", section)
     828            0 :                CALL set_restart_info("HELIUM DENSITIES", restarted_infos)
     829              :             END IF
     830              :             !
     831          216 :             CALL section_vals_val_set(r_section, "RESTART_FILE_NAME", c_val=" ")
     832          216 :             CALL section_vals_release(restart_file)
     833              :             CALL release_restart_info(restarted_infos, r_file_path, binary_restart_file, &
     834         5832 :                                       output_unit)
     835              :          END BLOCK
     836              :       END IF
     837        21167 :       CALL timestop(handle)
     838        21167 :    END SUBROUTINE handle_ext_restart
     839              : 
     840              : ! **************************************************************************************************
     841              : !> \brief store information on the restarted quantities
     842              : !> \param label ...
     843              : !> \param restarted_infos ...
     844              : !> \author Teodoro Laino [tlaino] 09.2008 - University of Zurich
     845              : ! **************************************************************************************************
     846         3550 :    SUBROUTINE set_restart_info(label, restarted_infos)
     847              : 
     848              :       CHARACTER(LEN=*), INTENT(IN)                       :: label
     849              :       CHARACTER(LEN=default_string_length), &
     850              :          DIMENSION(:), POINTER                           :: restarted_infos
     851              : 
     852              :       INTEGER                                            :: isize
     853              : 
     854         3550 :       isize = 0
     855         3336 :       IF (ASSOCIATED(restarted_infos)) isize = SIZE(restarted_infos)
     856         3550 :       isize = isize + 1
     857         3550 :       CALL reallocate(restarted_infos, 1, isize)
     858         3550 :       restarted_infos(isize) = TRIM(label)
     859              : 
     860         3550 :    END SUBROUTINE set_restart_info
     861              : 
     862              : ! **************************************************************************************************
     863              : !> \brief dumps on output the information on the information effectively restarted
     864              : !> \param restarted_infos ...
     865              : !> \param r_file_path ...
     866              : !> \param binary_restart_file ...
     867              : !> \param output_unit ...
     868              : !> \author Teodoro Laino [tlaino] 09.2008 - University of Zurich
     869              : ! **************************************************************************************************
     870          216 :    SUBROUTINE release_restart_info(restarted_infos, r_file_path, &
     871              :                                    binary_restart_file, output_unit)
     872              :       CHARACTER(LEN=default_string_length), &
     873              :          DIMENSION(:), POINTER                           :: restarted_infos
     874              :       CHARACTER(LEN=*), INTENT(IN)                       :: r_file_path, binary_restart_file
     875              :       INTEGER, INTENT(IN)                                :: output_unit
     876              : 
     877              :       INTEGER                                            :: i, j
     878              : 
     879          216 :       IF (output_unit > 0 .AND. ASSOCIATED(restarted_infos)) THEN
     880          107 :          WRITE (output_unit, '(1X,79("*"))')
     881          107 :          WRITE (output_unit, '(1X,"*",T30,A,T80,"*")') " RESTART INFORMATION "
     882          107 :          WRITE (output_unit, '(1X,79("*"))')
     883          107 :          WRITE (output_unit, '(1X,"*",T80,"*")')
     884          107 :          i = 1
     885          107 :          WRITE (output_unit, '(1X,"*",A,T26,A,T80,"*")') "    RESTART FILE NAME:  ", &
     886          214 :             r_file_path(53*(i - 1) + 1:53*i)
     887          107 :          DO i = 2, CEILING(REAL(LEN_TRIM(r_file_path), KIND=dp)/53.0_dp)
     888          107 :             WRITE (output_unit, '(T1,1X,"*",T26,A,T80,"*")') r_file_path(53*(i - 1) + 1:53*i)
     889              :          END DO
     890          107 :          IF (LEN_TRIM(binary_restart_file) > 0) THEN
     891           23 :             i = 1
     892           23 :             WRITE (output_unit, '(1X,"*",A,T26,A,T80,"*")') "  BINARY RESTART FILE:  ", &
     893           46 :                binary_restart_file(53*(i - 1) + 1:53*i)
     894           23 :             DO i = 2, CEILING(REAL(LEN_TRIM(binary_restart_file), KIND=dp)/53.0_dp)
     895           23 :                WRITE (output_unit, '(T1,1X,"*",T26,A,T80,"*")') binary_restart_file(53*(i - 1) + 1:53*i)
     896              :             END DO
     897              :          END IF
     898          107 :          WRITE (output_unit, '(1X,"*",T80,"*")')
     899          107 :          WRITE (output_unit, '(1X,"*", A,T80,"*")') " RESTARTED QUANTITIES:  "
     900         1882 :          DO j = 1, SIZE(restarted_infos)
     901         3657 :             DO i = 1, CEILING(REAL(LEN_TRIM(restarted_infos(j)), KIND=dp)/53.0_dp)
     902         3550 :                WRITE (output_unit, '(T1,1X,"*",T26,A,T80,"*")') restarted_infos(j) (53*(i - 1) + 1:53*i)
     903              :             END DO
     904              :          END DO
     905          107 :          WRITE (output_unit, '(1X,79("*"),/)')
     906              :       END IF
     907          216 :       IF (ASSOCIATED(restarted_infos)) THEN
     908          214 :          DEALLOCATE (restarted_infos)
     909              :       END IF
     910          216 :    END SUBROUTINE release_restart_info
     911              : 
     912              : ! **************************************************************************************************
     913              : !> \brief Possibly restart thermostats information
     914              : !> \param flag ...
     915              : !> \param input_file the input file to initialize
     916              : !> \param restart_file ...
     917              : !> \param path ...
     918              : !> \param check ...
     919              : !> \author Teodoro Laino [tlaino] 10.2007- University of Zurich
     920              : ! **************************************************************************************************
     921          266 :    SUBROUTINE restart_thermostat(flag, input_file, restart_file, path, check)
     922              :       LOGICAL, INTENT(IN)                                :: flag
     923              :       TYPE(section_vals_type), POINTER                   :: input_file, restart_file
     924              :       CHARACTER(LEN=*), INTENT(IN)                       :: path
     925              :       LOGICAL, INTENT(IN), OPTIONAL                      :: check
     926              : 
     927              :       INTEGER                                            :: input_region, input_type, &
     928              :                                                             restart_region, restart_type
     929              :       LOGICAL                                            :: check_loc, skip_other_checks
     930              :       TYPE(section_vals_type), POINTER                   :: section
     931              : 
     932          266 :       check_loc = check_restart(input_file, restart_file, TRIM(path))
     933          266 :       skip_other_checks = PRESENT(check)
     934          266 :       IF (skip_other_checks) check_loc = check
     935          266 :       IF (flag .AND. check_loc) THEN
     936              :          ! Let's check if the thermostat type is different otherwise it does not make any
     937              :          ! sense to do any kind of restart
     938          134 :          CALL section_vals_val_get(input_file, TRIM(path)//"%TYPE", i_val=input_type)
     939          134 :          CALL section_vals_val_get(restart_file, TRIM(path)//"%TYPE", i_val=restart_type)
     940              : 
     941          134 :          IF (input_type == do_thermo_same_as_part) THEN
     942           18 :             CALL section_vals_val_get(input_file, "MOTION%MD%THERMOSTAT%TYPE", i_val=input_type)
     943              :          END IF
     944              : 
     945          134 :          IF (skip_other_checks) THEN
     946           20 :             input_region = do_region_global
     947           20 :             restart_region = do_region_global
     948              :          ELSE
     949              :             ! Also the regions must be the same..
     950          114 :             CALL section_vals_val_get(input_file, TRIM(path)//"%REGION", i_val=input_region)
     951          114 :             CALL section_vals_val_get(restart_file, TRIM(path)//"%REGION", i_val=restart_region)
     952              :          END IF
     953              : 
     954          134 :          IF ((input_type == restart_type) .AND. (input_region == restart_region)) THEN
     955          110 :             SELECT CASE (input_type)
     956              :             CASE (do_thermo_nose)
     957          110 :                section => section_vals_get_subs_vals(restart_file, TRIM(path)//"%NOSE%COORD")
     958          110 :                CALL section_vals_set_subs_vals(input_file, TRIM(path)//"%NOSE%COORD", section)
     959              : 
     960          110 :                section => section_vals_get_subs_vals(restart_file, TRIM(path)//"%NOSE%VELOCITY")
     961          110 :                CALL section_vals_set_subs_vals(input_file, TRIM(path)//"%NOSE%VELOCITY", section)
     962              : 
     963          110 :                section => section_vals_get_subs_vals(restart_file, TRIM(path)//"%NOSE%MASS")
     964          110 :                CALL section_vals_set_subs_vals(input_file, TRIM(path)//"%NOSE%MASS", section)
     965              : 
     966          110 :                section => section_vals_get_subs_vals(restart_file, TRIM(path)//"%NOSE%FORCE")
     967          110 :                CALL section_vals_set_subs_vals(input_file, TRIM(path)//"%NOSE%FORCE", section)
     968              :             CASE (do_thermo_csvr)
     969           22 :                section => section_vals_get_subs_vals(restart_file, TRIM(path)//"%CSVR%THERMOSTAT_ENERGY")
     970           22 :                CALL section_vals_set_subs_vals(input_file, TRIM(path)//"%CSVR%THERMOSTAT_ENERGY", section)
     971           22 :                section => section_vals_get_subs_vals(restart_file, TRIM(path)//"%CSVR%RNG_INIT")
     972           22 :                CALL section_vals_set_subs_vals(input_file, TRIM(path)//"%CSVR%RNG_INIT", section)
     973              :             CASE (do_thermo_gle)
     974            2 :                section => section_vals_get_subs_vals(restart_file, TRIM(path)//"%GLE%THERMOSTAT_ENERGY")
     975            2 :                CALL section_vals_set_subs_vals(input_file, TRIM(path)//"%GLE%THERMOSTAT_ENERGY", section)
     976            2 :                section => section_vals_get_subs_vals(restart_file, TRIM(path)//"%GLE%RNG_INIT")
     977            2 :                CALL section_vals_set_subs_vals(input_file, TRIM(path)//"%GLE%RNG_INIT", section)
     978            2 :                section => section_vals_get_subs_vals(restart_file, TRIM(path)//"%GLE%S")
     979            2 :                CALL section_vals_set_subs_vals(input_file, TRIM(path)//"%GLE%S", section)
     980              :             CASE (do_thermo_al)
     981            0 :                section => section_vals_get_subs_vals(restart_file, TRIM(path)//"%AD_LANGEVIN%CHI")
     982            0 :                CALL section_vals_set_subs_vals(input_file, TRIM(path)//"%AD_LANGEVIN%CHI", section)
     983            0 :                section => section_vals_get_subs_vals(restart_file, TRIM(path)//"%AD_LANGEVIN%MASS")
     984          134 :                CALL section_vals_set_subs_vals(input_file, TRIM(path)//"%AD_LANGEVIN%MASS", section)
     985              :             END SELECT
     986              :          ELSE
     987            0 :             IF (input_type /= restart_type) THEN
     988              :                CALL cp_warn(__LOCATION__, &
     989              :                             "Requested to restart thermostat: "//TRIM(path)//". The thermostat "// &
     990              :                             "specified in the input file and the information present in the restart "// &
     991              :                             "file do not match the same type of thermostat! Restarting is not possible! "// &
     992            0 :                             "Thermostat will not be restarted! ")
     993              :             END IF
     994            0 :             IF (input_region /= restart_region) THEN
     995              :                CALL cp_warn(__LOCATION__, &
     996              :                             "Requested to restart thermostat: "//TRIM(path)//". The thermostat "// &
     997              :                             "specified in the input file and the information present in the restart "// &
     998              :                             "file do not match the same type of REGION! Restarting is not possible! "// &
     999            0 :                             "Thermostat will not be restarted! ")
    1000              :             END IF
    1001              :          END IF
    1002              :       END IF
    1003          266 :    END SUBROUTINE restart_thermostat
    1004              : 
    1005              : ! **************************************************************************************************
    1006              : !> \brief Checks if there are the proper conditions to do a restart
    1007              : !> \param input_file the input file to initialize
    1008              : !> \param restart_file ...
    1009              : !> \param tag_section ...
    1010              : !> \return ...
    1011              : !> \author teo
    1012              : ! **************************************************************************************************
    1013        13440 :    FUNCTION check_restart(input_file, restart_file, tag_section) RESULT(do_restart)
    1014              :       TYPE(section_vals_type), POINTER                   :: input_file, restart_file
    1015              :       CHARACTER(LEN=*), INTENT(IN)                       :: tag_section
    1016              :       LOGICAL                                            :: do_restart
    1017              : 
    1018              :       CHARACTER(len=*), PARAMETER                        :: routineN = 'check_restart'
    1019              : 
    1020              :       INTEGER                                            :: handle
    1021              :       LOGICAL                                            :: explicit1, explicit2
    1022              :       TYPE(section_vals_type), POINTER                   :: work_section
    1023              : 
    1024         4480 :       CALL timeset(routineN, handle)
    1025         4480 :       NULLIFY (work_section)
    1026         4480 :       work_section => section_vals_get_subs_vals(input_file, TRIM(tag_section))
    1027         4480 :       CALL section_vals_get(work_section, explicit=explicit1)
    1028         4480 :       work_section => section_vals_get_subs_vals(restart_file, TRIM(tag_section))
    1029         4480 :       CALL section_vals_get(work_section, explicit=explicit2)
    1030              : 
    1031         4480 :       do_restart = explicit1 .AND. explicit2
    1032         4480 :       CALL timestop(handle)
    1033         4480 :    END FUNCTION check_restart
    1034              : 
    1035              : ! **************************************************************************************************
    1036              : !> \brief Removes section used to restart a calculation from an
    1037              : !>      input file in memory
    1038              : !> \param input_file the input file to initialize
    1039              : !> \author teo
    1040              : ! **************************************************************************************************
    1041         7328 :    SUBROUTINE remove_restart_info(input_file)
    1042              :       TYPE(section_vals_type), POINTER                   :: input_file
    1043              : 
    1044              :       CHARACTER(len=*), PARAMETER :: routineN = 'remove_restart_info'
    1045              : 
    1046              :       INTEGER                                            :: handle, iforce_eval, nforce_eval1
    1047              :       LOGICAL                                            :: explicit1
    1048              :       TYPE(section_vals_type), POINTER                   :: md_section, motion_section, section1, &
    1049              :                                                             section_to_delete, sections1, &
    1050              :                                                             work_section
    1051              : 
    1052         1832 :       CALL timeset(routineN, handle)
    1053              : 
    1054         1832 :       NULLIFY (work_section)
    1055         1832 :       section_to_delete => section_vals_get_subs_vals(input_file, "EXT_RESTART")
    1056         1832 :       CALL section_vals_remove_values(section_to_delete)
    1057         1832 :       sections1 => section_vals_get_subs_vals(input_file, "FORCE_EVAL")
    1058         1832 :       CALL section_vals_get(sections1, n_repetition=nforce_eval1)
    1059              : 
    1060         3774 :       DO iforce_eval = 1, nforce_eval1
    1061         1942 :          section1 => section_vals_get_subs_vals3(sections1, "SUBSYS", i_rep_section=iforce_eval)
    1062         1942 :          section_to_delete => section_vals_get_subs_vals(section1, "COORD")
    1063         1942 :          CALL section_vals_remove_values(section_to_delete)
    1064         1942 :          section_to_delete => section_vals_get_subs_vals(section1, "VELOCITY")
    1065         3774 :          CALL section_vals_remove_values(section_to_delete)
    1066              :       END DO
    1067              : 
    1068         1832 :       motion_section => section_vals_get_subs_vals(input_file, "MOTION")
    1069         1832 :       md_section => section_vals_get_subs_vals(motion_section, "MD")
    1070         1832 :       CALL section_vals_get(md_section, explicit=explicit1)
    1071         1832 :       IF (explicit1) THEN
    1072         1772 :          CALL section_vals_val_unset(md_section, "STEP_START_VAL")
    1073         1772 :          CALL section_vals_val_unset(md_section, "TIME_START_VAL")
    1074         1772 :          CALL section_vals_val_unset(md_section, "ECONS_START_VAL")
    1075              :       END IF
    1076         1832 :       work_section => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN")
    1077         1832 :       CALL section_vals_get(work_section, explicit=explicit1)
    1078         1832 :       IF (explicit1) THEN
    1079          162 :          CALL section_vals_val_unset(motion_section, "FREE_ENERGY%METADYN%STEP_START_VAL")
    1080          162 :          CALL section_vals_val_unset(motion_section, "FREE_ENERGY%METADYN%NHILLS_START_VAL")
    1081              :       END IF
    1082         1832 :       section_to_delete => section_vals_get_subs_vals(motion_section, "BAND%REPLICA")
    1083         1832 :       CALL section_vals_remove_values(section_to_delete)
    1084         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "AVERAGES%RESTART_AVERAGES")
    1085         1832 :       CALL section_vals_remove_values(section_to_delete)
    1086         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "THERMOSTAT%NOSE%COORD")
    1087         1832 :       CALL section_vals_remove_values(section_to_delete)
    1088         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "THERMOSTAT%NOSE%VELOCITY")
    1089         1832 :       CALL section_vals_remove_values(section_to_delete)
    1090         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "THERMOSTAT%NOSE%MASS")
    1091         1832 :       CALL section_vals_remove_values(section_to_delete)
    1092         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "THERMOSTAT%NOSE%FORCE")
    1093         1832 :       CALL section_vals_remove_values(section_to_delete)
    1094         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "BAROSTAT%MASS")
    1095         1832 :       CALL section_vals_remove_values(section_to_delete)
    1096         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "BAROSTAT%VELOCITY")
    1097         1832 :       CALL section_vals_remove_values(section_to_delete)
    1098         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "BAROSTAT%THERMOSTAT%NOSE%COORD")
    1099         1832 :       CALL section_vals_remove_values(section_to_delete)
    1100         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "BAROSTAT%THERMOSTAT%NOSE%VELOCITY")
    1101         1832 :       CALL section_vals_remove_values(section_to_delete)
    1102         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "BAROSTAT%THERMOSTAT%NOSE%MASS")
    1103         1832 :       CALL section_vals_remove_values(section_to_delete)
    1104         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "BAROSTAT%THERMOSTAT%NOSE%FORCE")
    1105         1832 :       CALL section_vals_remove_values(section_to_delete)
    1106         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "SHELL%THERMOSTAT%NOSE%COORD")
    1107         1832 :       CALL section_vals_remove_values(section_to_delete)
    1108         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "SHELL%THERMOSTAT%NOSE%VELOCITY")
    1109         1832 :       CALL section_vals_remove_values(section_to_delete)
    1110         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "SHELL%THERMOSTAT%NOSE%MASS")
    1111         1832 :       CALL section_vals_remove_values(section_to_delete)
    1112         1832 :       section_to_delete => section_vals_get_subs_vals(md_section, "SHELL%THERMOSTAT%NOSE%FORCE")
    1113         1832 :       CALL section_vals_remove_values(section_to_delete)
    1114              :       ! Constrained/Restrained section
    1115         1832 :       section_to_delete => section_vals_get_subs_vals(motion_section, "CONSTRAINT%FIX_ATOM_RESTART")
    1116         1832 :       CALL section_vals_remove_values(section_to_delete)
    1117         1832 :       section_to_delete => section_vals_get_subs_vals(motion_section, "CONSTRAINT%COLVAR_RESTART")
    1118         1832 :       CALL section_vals_remove_values(section_to_delete)
    1119              :       ! Free energies restarts
    1120         1832 :       section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%SPAWNED_HILLS_POS")
    1121         1832 :       CALL section_vals_remove_values(section_to_delete)
    1122         1832 :       section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%SPAWNED_HILLS_SCALE")
    1123         1832 :       CALL section_vals_remove_values(section_to_delete)
    1124         1832 :       section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%SPAWNED_HILLS_HEIGHT")
    1125         1832 :       CALL section_vals_remove_values(section_to_delete)
    1126         1832 :       section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%SPAWNED_HILLS_INVDT")
    1127         1832 :       CALL section_vals_remove_values(section_to_delete)
    1128         1832 :       section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%EXT_LAGRANGE_SS0")
    1129         1832 :       CALL section_vals_remove_values(section_to_delete)
    1130         1832 :       section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%EXT_LAGRANGE_VVP")
    1131         1832 :       CALL section_vals_remove_values(section_to_delete)
    1132         1832 :       section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%EXT_LAGRANGE_SS")
    1133         1832 :       CALL section_vals_remove_values(section_to_delete)
    1134         1832 :       section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%EXT_LAGRANGE_FS")
    1135         1832 :       CALL section_vals_remove_values(section_to_delete)
    1136         1832 :       CALL timestop(handle)
    1137         1832 :    END SUBROUTINE remove_restart_info
    1138              : 
    1139              : ! **************************************************************************************************
    1140              : !> \brief This subroutine controls the defaults for the restartable quantities..
    1141              : !> \param r_section ...
    1142              : !> \author teo - University of Zurich - 09.2007 [tlaino]
    1143              : ! **************************************************************************************************
    1144          432 :    SUBROUTINE handle_defaults_restart(r_section)
    1145              :       TYPE(section_vals_type), POINTER                   :: r_section
    1146              : 
    1147              :       CHARACTER(len=*), PARAMETER :: routineN = 'handle_defaults_restart'
    1148              : 
    1149              :       INTEGER                                            :: handle, ik, nval
    1150              :       LOGICAL                                            :: restart_default
    1151              :       TYPE(keyword_type), POINTER                        :: keyword
    1152              :       TYPE(section_type), POINTER                        :: section
    1153              : 
    1154          216 :       CALL timeset(routineN, handle)
    1155          216 :       NULLIFY (keyword, section)
    1156          216 :       CALL section_vals_get(r_section, section=section)
    1157          216 :       CALL section_vals_val_get(r_section, "RESTART_DEFAULT", l_val=restart_default)
    1158         8856 :       DO ik = -1, section%n_keywords
    1159         8640 :          keyword => section%keywords(ik)%keyword
    1160         8856 :          IF (ASSOCIATED(keyword)) THEN
    1161         8208 :             IF (keyword%type_of_var == logical_t .AND. keyword%names(1) (1:8) == "RESTART_") THEN
    1162         7560 :                IF (TRIM(keyword%names(1)) == "RESTART_DEFAULT") CYCLE
    1163         7344 :                CALL section_vals_val_get(r_section, keyword%names(1), n_rep_val=nval)
    1164         7344 :                IF (nval == 0) THEN
    1165              :                   ! User didn't specify any value, use the value of the RESTART_DEFAULT keyword..
    1166         6366 :                   CALL section_vals_val_set(r_section, keyword%names(1), l_val=restart_default)
    1167              :                END IF
    1168              :             END IF
    1169              :          END IF
    1170              :       END DO
    1171          216 :       CALL timestop(handle)
    1172              : 
    1173          216 :    END SUBROUTINE handle_defaults_restart
    1174              : 
    1175              : END MODULE input_cp2k_check
        

Generated by: LCOV version 2.0-1