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
22program octopus
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 character(len=256) :: config_str
43 integer :: inp_calc_mode, ierr
44 type(block_t) :: blk
45
46 call getopt_init(ierr)
47 config_str = trim(get_config_opts()) // trim(get_optional_libraries())
48 if (ierr == 0) call getopt_octopus(trim(config_str))
49 call getopt_end()
50
51 call global_init()
52
53 call parser_init()
54
55 call messages_init()
56
57 call walltimer_init()
58
59 !%Variable ReportMemory
60 !%Type logical
61 !%Default no
62 !%Section Execution::Debug
63 !%Description
64 !% If true, after each SCF iteration <tt>Octopus</tt> will print
65 !% information about the memory the code is using. The quantity
66 !% reported is an approximation to the size of the heap and
67 !% generally it is a lower bound to the actual memory <tt>Octopus</tt> is
68 !% using.
69 !%End
70 call parse_variable(global_namespace, 'ReportMemory', .false., conf%report_memory)
71
72 ! need to find out calc_mode already here since some of the variables here (e.g.
73 ! periodic dimensions) can be different for the subsystems
74
75 !%Variable CalculationMode
76 !%Type integer
77 !%Default gs
78 !%Section Calculation Modes
79 !%Description
80 !% Decides what kind of calculation is to be performed.
81 !%Option gs 01
82 !% Calculation of the ground state.
83 !%Option unocc 02
84 !% Calculation of unoccupied/virtual KS states. Can also be used for a non-self-consistent
85 !% calculation of states at arbitrary k-points, if <tt>density.obf</tt> from <tt>gs</tt>
86 !% is provided in the <tt>restart/gs</tt> directory.
87 !%Option td 03
88 !% Time-dependent calculation (experimental for periodic systems).
89 !%Option go 05
90 !% Optimization of the geometry.
91 !%Option opt_control 07
92 !% Optimal control.
93 !%Option em_resp 08
94 !% Calculation of the electromagnetic response: electric
95 !% polarizabilities and hyperpolarizabilities and magnetic
96 !% susceptibilities (experimental for periodic systems).
97 !%Option casida 09
98 !% Excitations via Casida linear-response TDDFT; for finite systems only.
99 !%Option vdw 11
100 !% Calculate van der Waals coefficients.
101 !%Option vib_modes 12
102 !% Calculation of the vibrational modes.
103 !%Option one_shot 14
104 !% Obsolete. Use <tt>gs</tt> with <tt>MaximumIter = 0</tt> instead.
105 !%Option kdotp 15
106 !% Calculation of effective masses by <math>\vec{k} \cdot \vec{p}</math> perturbation theory (experimental).
107 !%Option dummy 17
108 !% This calculation mode does nothing. Useful for debugging, testing and benchmarking.
109 !%Option invert_ks 18
110 !% Invert the Kohn-Sham equations (experimental).
111 !%Option test 19
112 !%Option recipe 99
113 !% Prints out a tasty recipe.
114 !%End
115 if (parse_block(global_namespace, 'CalculationMode', blk) == 0) then
116 call messages_write('The datasets mode has been deprecated,', new_line = .true.)
117 call messages_write('please use several Octopus runs.')
118 call messages_fatal()
119 end if
120
121 call parse_variable(global_namespace, 'CalculationMode', option__calculationmode__gs, inp_calc_mode)
122 if (.not. varinfo_valid_option('CalculationMode', inp_calc_mode)) call messages_input_error(global_namespace, 'CalculationMode')
123
124 ! Now we can initialize the I/O
125 call io_init()
126
127 ! now we declare octopus as running
128 call messages_switch_status('running')
129
131
132 call print_header()
133
134 ! now we really start
135 call run(global_namespace, inp_calc_mode)
136
137 ! wait for all processors to finish
138 call mpi_world%barrier()
139
140 ! run finished successfully
141 call messages_switch_status('finished')
142 call io_end()
143
145
146 call walltimer_end()
147
148 call print_date("Calculation ended on ")
149 call print_walltime()
150
151 call messages_end()
152
153 call parser_end()
154
155 call global_end()
156
157contains
158
159 subroutine print_walltime()
160 integer :: days, hours, min, sec, usec
161
162 call loct_gettimeofday(sec, usec)
163 call epoch_time_diff(sec, usec)
164
165 days = sec / 86400
166 hours = (sec / 3600) - (days * 24)
167 min = (sec / 60) - (days * 1440) - (hours * 60)
168 sec = modulo(sec, 60)
169
170 message(2) = ''
171 if (days > 0) write(message(2), '(i3,a)') days, ' days,'
172 if (hours > 0.or.message(2) /= '') then
173 write(message(2), '(a,1x,i2.2,a)') trim(message(2)), hours, 'h'
174 end if
175 if (min > 0.or.message(1) /= '') then
176 write(message(2), '(a,1x,i2.2,a)') trim(message(2)), min, 'm'
177 end if
178 write(message(2), '(a,1x,i2.2,a,i3,a)') trim(message(2)), sec, '.', usec/1000, 's'
179 message(1) = str_center('Walltime: ' // trim(message(2)), 70)
180 call messages_info(1)
181
182 end subroutine print_walltime
183
184end program octopus
185
186!! Local Variables:
187!! mode: f90
188!! coding: utf-8
189!! End:
Each program/utility that needs to use the getopt features should have an interface here – the defini...
subroutine print_walltime()
Definition: main.F90:253
This module handles the calculation mode.
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:388
subroutine, public global_end()
Finalise parser varinfo file, and MPI.
Definition: global.F90:381
type(conf_t), public conf
Global instance of Octopus configuration.
Definition: global.F90:177
subroutine, public global_init(communicator)
Initialise Octopus.
Definition: global.F90:324
Definition: io.F90:114
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:166
subroutine, public io_end()
Definition: io.F90:265
subroutine, public messages_end()
Definition: messages.F90:277
subroutine, public messages_init(output_dir)
Definition: messages.F90:224
subroutine, public messages_switch_status(status)
create status file for asynchronous communication
Definition: messages.F90:677
subroutine, public print_date(str)
Definition: messages.F90:1017
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
Definition: messages.F90:624
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:160
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:420
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:723
type(mpi_grp_t), public mpi_world
Definition: mpi.F90:266
type(namespace_t), public global_namespace
Definition: namespace.F90:132
Exported library interface.
Definition: octopus.F90:26
subroutine, public parser_init()
Initialise the Octopus parser.
Definition: parser.F90:450
subroutine, public parser_end()
End the Octopus parser.
Definition: parser.F90:481
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:618
subroutine, public profiling_end(namespace)
Definition: profiling.F90:413
subroutine, public profiling_init(namespace)
Create profiling subdirectory.
Definition: profiling.F90:255
top level module for all calculation modes
Definition: run.F90:117
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:212
character(len=80) function, public str_center(s_in, l_in)
puts space around string, so that it is centered
Definition: string.F90:197
This module is intended to contain simple general-purpose utility functions and procedures.
Definition: utils.F90:118
character(len=256) function, public get_config_opts()
Definition: utils.F90:360
character(len=256) function, public get_optional_libraries()
Definition: utils.F90:383
subroutine, public print_header()
This subroutine prints the logo followed by information about the compilation and the system....
Definition: utils.F90:301
This module provices a simple timer class which can be used to trigger the writing of a restart file ...
Definition: walltimer.F90:121
subroutine, public walltimer_init(auto)
initialize the timer
Definition: walltimer.F90:159
subroutine, public walltimer_end()
destructor
Definition: walltimer.F90:220
int true(void)