LCOV - code coverage report
Current view: top level - src/swarm - swarm_input.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:262480d) Lines: 29 29 100.0 %
Date: 2024-11-22 07:00:40 Functions: 1 1 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2024 CP2K developers group <https://cp2k.org>                                   !
       4             : !                                                                                                  !
       5             : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6             : !--------------------------------------------------------------------------------------------------!
       7             : 
       8             : ! **************************************************************************************************
       9             : !> \brief Declares the input for swarm framework
      10             : !> \author Ole Schuett
      11             : ! **************************************************************************************************
      12             : MODULE swarm_input
      13             :    USE cp_output_handling,              ONLY: add_last_numeric,&
      14             :                                               cp_print_key_section_create,&
      15             :                                               low_print_level
      16             :    USE glbopt_input,                    ONLY: glbopt_declare_input
      17             :    USE input_constants,                 ONLY: swarm_do_glbopt
      18             :    USE input_keyword_types,             ONLY: keyword_create,&
      19             :                                               keyword_release,&
      20             :                                               keyword_type
      21             :    USE input_section_types,             ONLY: section_add_keyword,&
      22             :                                               section_add_subsection,&
      23             :                                               section_create,&
      24             :                                               section_release,&
      25             :                                               section_type
      26             :    USE input_val_types,                 ONLY: integer_t
      27             :    USE string_utilities,                ONLY: s2a
      28             : #include "../base/base_uses.f90"
      29             : 
      30             :    IMPLICIT NONE
      31             :    PRIVATE
      32             : 
      33             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'swarm_input'
      34             : 
      35             :    PUBLIC :: create_swarm_section
      36             : 
      37             : CONTAINS
      38             : 
      39             : ! **************************************************************************************************
      40             : !> \brief Declares the SWARM input section
      41             : !> \param swarm_section ...
      42             : !> \author Ole Schuett
      43             : ! **************************************************************************************************
      44        8530 :    SUBROUTINE create_swarm_section(swarm_section)
      45             :       TYPE(section_type), POINTER                        :: swarm_section
      46             : 
      47             :       TYPE(keyword_type), POINTER                        :: keyword
      48             :       TYPE(section_type), POINTER                        :: print_section, printkey
      49             : 
      50        8530 :       NULLIFY (swarm_section, print_section, printkey, keyword)
      51             : 
      52             :       CALL section_create(swarm_section, __LOCATION__, name="SWARM", &
      53             :                           description="Section to control swarm runs. "// &
      54             :                           "The swarm framework provides a common ground for master/worker algorithms.", &
      55        8530 :                           repeats=.FALSE.)
      56             : 
      57             :       CALL keyword_create(keyword, __LOCATION__, name="BEHAVIOR", &
      58             :                           description="Which behaviour should control the swarm.", &
      59             :                           usage="BEHAVIOR <STRING>", &
      60             :                           default_i_val=swarm_do_glbopt, &
      61             :                           enum_c_vals=s2a("GLOBAL_OPT"), &
      62             :                           enum_desc=s2a("Runs global geometry optimisation"), &
      63        8530 :                           enum_i_vals=(/swarm_do_glbopt/))
      64        8530 :       CALL section_add_keyword(swarm_section, keyword)
      65        8530 :       CALL keyword_release(keyword)
      66             : 
      67             :       CALL keyword_create(keyword, __LOCATION__, name="NUMBER_OF_WORKERS", &
      68             :                           description="Number of workers used for swarm. "// &
      69             :                           "Of the total number of processors one is used for the master, "// &
      70             :                           "the remaining processors should be divisible by the number of workers.", &
      71        8530 :                           type_of_var=integer_t)
      72        8530 :       CALL section_add_keyword(swarm_section, keyword)
      73        8530 :       CALL keyword_release(keyword)
      74             : 
      75             :       CALL keyword_create(keyword, __LOCATION__, name="REPLAY_COMMUNICATION_LOG", &
      76             :                           description="Filename of communication log of previous run. Use this to restart a swarm.", &
      77             :                           repeats=.FALSE., &
      78        8530 :                           usage="REPLAY_COMMUNICATION_LOG <CHARACTER>", default_lc_val="swarm_translog_replay.xyz")
      79        8530 :       CALL section_add_keyword(swarm_section, keyword)
      80        8530 :       CALL keyword_release(keyword)
      81             : 
      82             :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
      83             :                           description="The maximum number iterations the master should perform", &
      84        8530 :                           type_of_var=integer_t, default_i_val=HUGE(1))
      85        8530 :       CALL section_add_keyword(swarm_section, keyword)
      86        8530 :       CALL keyword_release(keyword)
      87             : 
      88             :       CALL section_create(print_section, __LOCATION__, name="PRINT", &
      89             :                           description="Controls the printing properties during a global optimization run", &
      90        8530 :                           n_keywords=0, n_subsections=1, repeats=.TRUE.)
      91             : 
      92             :       CALL cp_print_key_section_create( &
      93             :          printkey, __LOCATION__, "WORKER_RUN_INFO", &
      94             :          description="Controls the printing of the worker's basic information during the global optimization", &
      95        8530 :          print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
      96        8530 :       CALL section_add_subsection(print_section, printkey)
      97        8530 :       CALL section_release(printkey)
      98             : 
      99             :       CALL cp_print_key_section_create( &
     100             :          printkey, __LOCATION__, "MASTER_RUN_INFO", &
     101             :          description="Controls the printing of the masters's basic information during the global optimization", &
     102        8530 :          print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
     103        8530 :       CALL section_add_subsection(print_section, printkey)
     104        8530 :       CALL section_release(printkey)
     105             : 
     106             :       CALL cp_print_key_section_create(printkey, __LOCATION__, "COMMUNICATION_LOG", &
     107             :                                        description="Log all the communication between workers and master. Needed for restart.", &
     108             :                                        print_level=low_print_level, common_iter_levels=1, &
     109        8530 :                                        filename="", unit_str="angstrom")
     110        8530 :       CALL section_add_subsection(print_section, printkey)
     111        8530 :       CALL section_release(printkey)
     112             : 
     113        8530 :       CALL section_add_subsection(swarm_section, print_section)
     114        8530 :       CALL section_release(print_section)
     115             : 
     116        8530 :       CALL glbopt_declare_input(swarm_section)
     117             : 
     118        8530 :    END SUBROUTINE create_swarm_section
     119             : 
     120             : END MODULE swarm_input
     121             : 

Generated by: LCOV version 1.15