Octopus
main.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
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
20#include "global.h"
21
25 use debug_oct_m
26 use io_oct_m
27 use global_oct_m
28 use loct_oct_m
30 use mpi_oct_m
32 use parser_oct_m
34 use run_oct_m
35 use string_oct_m
36 use utils_oct_m
39
40 implicit none
41
42 private
43 public :: octopus_main
44
45contains
46
47 subroutine octopus_main() bind(c)
48 character(len=256) :: config_str
49 logical :: silence_progress_bar
50 integer :: inp_calc_mode, ierr
51 type(block_t) :: blk
52
53 call getopt_init(ierr)
54 config_str = trim(get_config_opts()) // trim(get_optional_libraries())
55 if (ierr == 0) call getopt_octopus(trim(config_str))
56 call getopt_end()
57
58 call global_init()
59
60 call parser_init()
61
62 call messages_init()
63
64 call walltimer_init()
65
66 !%Variable ReportMemory
67 !%Type logical
68 !%Default no
69 !%Section Execution::Debug
70 !%Description
71 !% If true, after each SCF iteration <tt>Octopus</tt> will print
72 !% information about the memory the code is using. The quantity
73 !% reported is an approximation to the size of the heap and
74 !% generally it is a lower bound to the actual memory <tt>Octopus</tt> is
75 !% using.
76 !%End
77 call parse_variable(global_namespace, 'ReportMemory', .false., conf%report_memory)
78
79 !%Variable SilenceProgressBar
80 !%Type logical
81 !%Default yes
82 !%Section Execution
83 !%Description
84 !% Suppress output of the progress bar, which is useful when <tt>Octopus</tt>
85 !% is not attached to an interactive terminal.
86 !%End
87 call parse_variable(global_namespace, 'SilenceProgressBar', .false., silence_progress_bar)
88 show_progress_bar = show_progress_bar.and. .not.silence_progress_bar
89
90 ! need to find out calc_mode already here since some of the variables here (e.g.
91 ! periodic dimensions) can be different for the subsystems
92
93 !%Variable CalculationMode
94 !%Type integer
95 !%Default gs
96 !%Section Calculation Modes
97 !%Description
98 !% Decides what kind of calculation is to be performed.
99 !%Option gs 01
100 !% Calculation of the ground state.
101 !%Option unocc 02
102 !% Calculation of unoccupied/virtual KS states. Can also be used for a non-self-consistent
103 !% calculation of states at arbitrary k-points, if <tt>density.obf</tt> from <tt>gs</tt>
104 !% is provided in the <tt>restart/gs</tt> directory.
105 !%Option td 03
106 !% Time-dependent calculation (experimental for periodic systems).
107 !%Option go 05
108 !% Optimization of the geometry.
109 !%Option opt_control 07
110 !% Optimal control.
111 !%Option em_resp 08
112 !% Calculation of the electromagnetic response: electric
113 !% polarizabilities and hyperpolarizabilities and magnetic
114 !% susceptibilities (experimental for periodic systems).
115 !%Option casida 09
116 !% Excitations via Casida linear-response TDDFT; for finite systems only.
117 !%Option vdw 11
118 !% Calculate van der Waals coefficients.
119 !%Option vib_modes 12
120 !% Calculation of the vibrational modes.
121 !%Option one_shot 14
122 !% Obsolete. Use <tt>gs</tt> with <tt>MaximumIter = 0</tt> instead.
123 !%Option kdotp 15
124 !% Calculation of effective masses by <math>\vec{k} \cdot \vec{p}</math> perturbation theory (experimental).
125 !%Option dummy 17
126 !% This calculation mode does nothing. Useful for debugging, testing and benchmarking.
127 !%Option invert_ks 18
128 !% Invert the Kohn-Sham equations (experimental).
129 !%Option test 19
130 !%Option recipe 99
131 !% Prints out a tasty recipe.
132 !%End
133 if (parse_block(global_namespace, 'CalculationMode', blk) == 0) then
134 call messages_write('The datasets mode has been deprecated,', new_line = .true.)
135 call messages_write('please use several Octopus runs.')
136 call messages_fatal()
137 end if
138
139 call parse_variable(global_namespace, 'CalculationMode', option__calculationmode__gs, inp_calc_mode)
140 if (.not. varinfo_valid_option('CalculationMode', inp_calc_mode)) call messages_input_error(global_namespace, 'CalculationMode')
141
142 ! Now we can initialize the I/O
143 call io_init()
144
145 ! now we declare octopus as running
146 call messages_switch_status('running')
147
149
150 call print_header()
151
152 ! now we really start
153 call run(global_namespace, inp_calc_mode)
154
155 ! wait for all processors to finish
156 call mpi_world%barrier()
157
158 ! run finished successfully
159 call messages_switch_status('finished')
160 call io_end()
161
163
164 call walltimer_end()
165
166 call print_date("Calculation ended on ")
167 call print_walltime()
168
169 call messages_end()
170
171 call parser_end()
172
173 call global_end()
174
175 contains
176
177 subroutine print_walltime()
178 integer :: days, hours, min, sec, usec
179
180 call loct_gettimeofday(sec, usec)
181 call epoch_time_diff(sec, usec)
182
183 days = sec / 86400
184 hours = (sec / 3600) - (days * 24)
185 min = (sec / 60) - (days * 1440) - (hours * 60)
186 sec = modulo(sec, 60)
187
188 message(2) = ''
189 if (days > 0) write(message(2), '(i3,a)') days, ' days,'
190 if (hours > 0 .or. message(2) /= '') then
191 write(message(2), '(a,1x,i2.2,a)') trim(message(2)), hours, 'h'
192 end if
193 if (min > 0 .or. message(2) /= '') then
194 write(message(2), '(a,1x, i2.2,a)') trim(message(2)), min, 'm'
195 end if
196 write(message(2), '(a,i2.2,a,i3.3,a)') trim(message(2)), sec, '.', usec/1000, 's'
197 message(1) = str_center('Walltime: ' // trim(message(2)), 70)
198 call messages_info(1)
199
200 end subroutine print_walltime
201
202 end subroutine octopus_main
203end module octopus_main_oct_m
204
205!! Local Variables:
206!! mode: f90
207!! coding: utf-8
208!! End:
subroutine print_walltime()
Definition: main.F90:250
This module handles the calculation mode.
This module provides an interface to the getopt C library, so that the command line arguments can be ...
subroutine, public getopt_octopus(config_str)
subroutine, public getopt_init(ierr)
Initializes the getopt machinery. Must be called before attempting to parse the options....
subroutine, public getopt_end
subroutine, public epoch_time_diff(sec, usec)
Definition: debug.F90:382
subroutine, public global_end()
Finalise parser varinfo file, and MPI.
Definition: global.F90:500
type(conf_t), public conf
Global instance of Octopus configuration.
Definition: global.F90:163
subroutine, public global_init(communicator)
Initialise Octopus.
Definition: global.F90:381
Definition: io.F90:93
subroutine, public io_init(defaults)
If the argument defaults is present and set to true, then the routine will not try to read anything f...
Definition: io.F90:142
subroutine, public io_end()
Definition: io.F90:248
System information (time, memory, sysname)
Definition: loct.F90:94
logical, public show_progress_bar
Define which routines can be seen from the outside.
Definition: loct.F90:126
subroutine, public messages_end()
Definition: messages.F90:249
subroutine, public messages_init(output_dir)
Definition: messages.F90:196
subroutine, public messages_switch_status(status)
create status file for asynchronous communication
Definition: messages.F90:621
subroutine, public print_date(str)
Definition: messages.F90:963
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:138
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:386
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:671
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:570
type(mpi_grp_t), public mpi_world
Definition: mpi.F90:317
type(namespace_t), public global_namespace
Definition: namespace.F90:112
subroutine, public octopus_main()
Definition: main.F90:120
subroutine, public parser_init()
Initialise the Octopus parser.
Definition: parser.F90:387
subroutine, public parser_end()
End the Octopus parser.
Definition: parser.F90:419
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:600
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
Definition: profiling.F90:122
subroutine, public profiling_end(namespace)
Definition: profiling.F90:455
subroutine, public profiling_init(namespace)
Create profiling subdirectory.
Definition: profiling.F90:264
top level module for all calculation modes
Definition: run.F90:96
subroutine, public run(namespace, calc_mode_id)
main routine to run all calculations: This routine parses the input file, sets up the systems and int...
Definition: run.F90:199
character(len=80) function, public str_center(s_in, l_in)
puts space around string, so that it is centered
Definition: string.F90:153
This module is intended to contain simple general-purpose utility functions and procedures.
Definition: utils.F90:99
character(len=256) function, public get_config_opts()
Character string containing compile-time options.
Definition: utils.F90:353
character(len=256) function, public get_optional_libraries()
Character string containing optional external libraries.
Definition: utils.F90:362
subroutine, public print_header()
This subroutine prints the logo followed by information about the compilation and the system....
Definition: utils.F90:290
This module provides a simple timer class which can be used to trigger the writing of a restart file ...
Definition: walltimer.F90:100
subroutine, public walltimer_init(auto)
initialize the timer
Definition: walltimer.F90:138
subroutine, public walltimer_end()
destructor
Definition: walltimer.F90:227
int true(void)