Octopus
run_multisystem.F90
Go to the documentation of this file.
1!! Copyright (C) 2019-2024 M. Oliveira, H. Appel, N. Tancogne-Dejean
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
22 use debug_oct_m
24 use global_oct_m
29 use parser_oct_m
32 use system_oct_m
33 use td_oct_m
35
36 implicit none
37
38 private
39 public :: multisystem_run
40
41contains
42
43 ! ---------------------------------------------------------
44 subroutine multisystem_run(systems, from_scratch)
45 class(multisystem_basic_t), intent(inout) :: systems
46 logical, intent(in) :: from_scratch
47
48 logical :: trigger_restart, stop_code, stop_loop
49 logical :: restart_read
50
51 push_sub(multisystem_run)
52
53 call multisystem_debug_init("debug/multisystem_execution.log", global_namespace, systems%grp)
54
55 call messages_write('Info: Running Multi-system calculation')
56 call messages_info(namespace=systems%namespace)
57
58 ! Read restart files or set initial conditions
59 call systems%init_iteration_counters()
60 if (.not. from_scratch) then
61 restart_read = systems%restart_read()
62 else
63 restart_read = .false.
64 end if
65 if (restart_read) then
66 message(1) = "Successfully read restart data for all system."
67 call messages_info(1, namespace=systems%namespace)
68 else
69 call systems%initialize()
70 end if
71
72 call systems%algorithm_start()
73
74 call multisystem_debug_write_marker(systems%namespace, event_marker_t("multisystem_run_start"))
75
76 ! The full loop
77 stop_loop = .false.
78 do while (.not. systems%algorithm_finished())
79 ! Execute algorithm until next barrier
80 call systems%execute_algorithm()
81
82 ! determine cases in which to trigger writing restart files
83 stop_code = clean_stop(systems%grp%comm) .or. walltimer_alarm(systems%grp%comm)
84 trigger_restart = stop_code .or. restart_walltime_period_alarm(systems%grp%comm)
85
86 if (trigger_restart .and. .not. stop_loop) then
87 call systems%start_barrier(systems%next_time_on_largest_dt(), barrier_restart)
88 stop_loop = stop_code
89 trigger_restart = .false.
90 end if
91 if (systems%arrived_at_barrier(barrier_restart)) then
92 call systems%restart_write()
93 call systems%end_barrier(barrier_restart)
94 if (stop_loop) exit
95 end if
96 end do
97
98 if (systems%algorithm_finished()) then
99 call systems%restart_write()
100 end if
101
102 call multisystem_debug_write_marker(systems%namespace, event_marker_t("multisystem_run_finish"))
103
104 call systems%algorithm_finish()
105
107
108 pop_sub(multisystem_run)
109 end subroutine multisystem_run
110
111end module multisystem_run_oct_m
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:160
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:624
This module implements the basic mulsisystem class, a container system for other systems.
This module implements the multisystem debug functionality.
subroutine, public multisystem_debug_write_marker(system_namespace, event)
subroutine, public multisystem_debug_init(filename, namespace, group)
subroutine, public multisystem_debug_end()
subroutine, public multisystem_run(systems, from_scratch)
type(namespace_t), public global_namespace
Definition: namespace.F90:132
logical function, public clean_stop(comm)
returns true if a file named stop exists
Definition: restart.F90:276
This module implements the abstract system type.
Definition: system.F90:118
integer, parameter, public barrier_restart
Definition: system.F90:165
Definition: td.F90:114
This module provices a simple timer class which can be used to trigger the writing of a restart file ...
Definition: walltimer.F90:121
logical function, public walltimer_alarm(comm, print)
indicate whether time is up
Definition: walltimer.F90:303
logical function, public restart_walltime_period_alarm(comm)
Definition: walltimer.F90:343