(git:d3d49ac)
Loading...
Searching...
No Matches
farming_types.F
Go to the documentation of this file.
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! **************************************************************************************************
10
11 USE kinds, ONLY: default_path_length,&
12 dp
13#include "./base/base_uses.f90"
14
15 IMPLICIT NONE
16 PRIVATE
17
19
20 INTEGER, PUBLIC, PARAMETER :: job_pending = 1, job_running = 2, job_finished = 3
21
22! **************************************************************************************************
23 TYPE job_type
24 CHARACTER(LEN=default_path_length) :: cwd = "" ! the directory to go to
25 CHARACTER(LEN=default_path_length) :: input = "" ! the input file to use
26 CHARACTER(LEN=default_path_length) :: output = "" ! the output file to use
27 INTEGER :: id = -1 ! the ID of this job
28 INTEGER, POINTER, DIMENSION(:) :: dependencies => null() ! the dependencies of this job
29 INTEGER :: status = -1 ! pending,running,finished
30 END TYPE job_type
31
32! **************************************************************************************************
34 INTEGER :: group_size_wish = -1
35 LOGICAL :: group_size_wish_set = .false.
36 INTEGER :: ngroup_wish = -1
37 LOGICAL :: ngroup_wish_set = .false.
38 LOGICAL :: restart = .false.
39 LOGICAL :: cycle = .false.
40 LOGICAL :: captain_minion = .false.
41 ! user preference for partitioning the cpus
42 INTEGER, DIMENSION(:), POINTER :: group_partition => null()
43 CHARACTER(LEN=default_path_length) :: restart_file_name = "" ! restart file for farming
44 CHARACTER(LEN=default_path_length) :: cwd = "" ! directory we started from
45 INTEGER :: njobs = -1 ! how many jobs to run
46 INTEGER :: restart_n = -1 ! where to start
47 INTEGER :: max_steps = -1 ! max number of steps,
48 ! results in max_steps*Ngroup jobs being run
49 INTEGER :: stride = -1 ! for creating minion groups.
50 TYPE(job_type), DIMENSION(:), POINTER :: job => null() ! a list of jobs
51 REAL(kind=dp) :: wait_time = 0.0_dp
52 END TYPE farming_env_type
53
54CONTAINS
55
56! **************************************************************************************************
57!> \brief help poor compilers do their job
58!> i.e. provide a default initialization
59!> \param farming_env an associated farming env pointer
60!> \par History
61!> 03.2004 created [Joost VandeVondele ]
62! **************************************************************************************************
63 SUBROUTINE init_farming_env(farming_env)
64 TYPE(farming_env_type), POINTER :: farming_env
65
66 IF (ASSOCIATED(farming_env)) THEN
67 farming_env%group_size_wish = 0
68 farming_env%group_size_wish_set = .false.
69 farming_env%ngroup_wish = 0
70 farming_env%ngroup_wish_set = .false.
71 farming_env%restart = .false.
72 farming_env%restart_n = 1
73 farming_env%cycle = .false.
74 farming_env%captain_minion = .false.
75 NULLIFY (farming_env%group_partition)
76 farming_env%cwd = "."
77 farming_env%Njobs = 0
78 ! so that maxsteps*ngroup is (likely) not overflowing
79 farming_env%max_steps = 65535
80 NULLIFY (farming_env%Job)
81 END IF
82 END SUBROUTINE init_farming_env
83
84! **************************************************************************************************
85!> \brief provide a default initialization
86!> \param job ...
87!> \par History
88!> 09.2007 created [Joost VandeVondele ]
89! **************************************************************************************************
90 ELEMENTAL SUBROUTINE init_job_type(job)
91 TYPE(job_type), INTENT(OUT) :: job
92
93 job%cwd = ""
94 job%input = ""
95 job%output = ""
96 job%ID = -1
97 job%status = job_pending
98 NULLIFY (job%dependencies)
99
100 END SUBROUTINE init_job_type
101
102! **************************************************************************************************
103!> \brief deallocates all memory associated with this job
104!> \param job ...
105!> \par History
106!> 09.2007 created [Joost VandeVondele ]
107! **************************************************************************************************
108 SUBROUTINE deallocate_job_type(job)
109 TYPE(job_type) :: job
110
111 IF (ASSOCIATED(job%dependencies)) DEALLOCATE (job%dependencies)
112
113 END SUBROUTINE deallocate_job_type
114
115! **************************************************************************************************
116!> \brief deallocates all associated fields of the farming_env type
117!> and the type itself
118!> \param farming_env ...
119!> \par History
120!> 03.2004 created [Joost VandeVondele]
121! **************************************************************************************************
122 SUBROUTINE deallocate_farming_env(farming_env)
123 TYPE(farming_env_type), POINTER :: farming_env
124
125 INTEGER :: i
126
127 IF (ASSOCIATED(farming_env)) THEN
128 IF (ASSOCIATED(farming_env%job)) THEN
129 DO i = 1, SIZE(farming_env%job, 1)
130 CALL deallocate_job_type(farming_env%job(i))
131 END DO
132 DEALLOCATE (farming_env%job)
133 END IF
134 IF (ASSOCIATED(farming_env%group_partition)) DEALLOCATE (farming_env%group_partition)
135 DEALLOCATE (farming_env) ! and the type itself
136 END IF
137 END SUBROUTINE deallocate_farming_env
138END MODULE farming_types
elemental subroutine, public init_job_type(job)
provide a default initialization
subroutine, public deallocate_farming_env(farming_env)
deallocates all associated fields of the farming_env type and the type itself
integer, parameter, public job_finished
integer, parameter, public job_running
integer, parameter, public job_pending
subroutine, public init_farming_env(farming_env)
help poor compilers do their job i.e. provide a default initialization
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_path_length
Definition kinds.F:58