Octopus
space.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#include "global.h"
20
21module space_oct_m
22 use debug_oct_m
23 use global_oct_m
26 use parser_oct_m
28
29 implicit none
30
31 private
32
33 public :: &
35
36
37 type space_t
38 ! Components are public by default
39 integer :: dim
40 integer :: periodic_dim = 0
41
42 contains
43 procedure :: is_periodic => space_is_periodic
44 procedure :: has_mixed_periodicity => space_has_mixed_periodicity
45 procedure :: write_info => space_write_info
46 procedure :: short_info => space_short_info
47 end type space_t
48
49 interface space_t
50 procedure space_constructor
51 end interface space_t
52
53contains
54
55 !----------------------------------------------------------
56 function space_constructor(namespace) result(this)
57 type(space_t) :: this
58 type(namespace_t), intent(in) :: namespace
59
60 integer, parameter :: default_ndim = 3
61
62 push_sub(space_constructor)
63
64 !%Variable Dimensions
65 !%Type integer
66 !%Section System
67 !%Default 3
68 !%Description
69 !% <tt>Octopus</tt> can run in 1, 2 or 3 or more dimensions, depending on
70 !% the value of this variable. Note that not all input variables may be
71 !% available in all cases.
72 !%End
73 call parse_variable(namespace, 'Dimensions', default_ndim, this%dim)
74 if (this%dim < 1) call messages_input_error(namespace, 'Dimensions')
75
76 !%Variable PeriodicDimensions
77 !%Type integer
78 !%Default 0
79 !%Section System
80 !%Description
81 !% Define how many directions are to be considered periodic. It has to be a number
82 !% between zero and <tt>Dimensions</tt>.
83 !%Option 0
84 !% No direction is periodic (molecule).
85 !%Option 1
86 !% The <i>x</i> direction is periodic.
87 !%Option 2
88 !% The <i>x</i> and <i>y</i> directions are periodic.
89 !%Option 3
90 !% The <i>x</i>, <i>y</i>, and <i>z</i> directions are periodic.
91 !%End
92 call parse_variable(namespace, 'PeriodicDimensions', 0, this%periodic_dim)
93
94 if ((this%periodic_dim < 0) .or. (this%periodic_dim > this%dim)) then
95 call messages_input_error(namespace, 'PeriodicDimensions')
96 end if
97
98 pop_sub(space_constructor)
99 end function space_constructor
100
101 !--------------------------------------------------------------
102 logical pure function space_is_periodic(this)
103 class(space_t), intent(in) :: this
104
105 space_is_periodic = this%periodic_dim > 0
106
107 end function space_is_periodic
108
109 !--------------------------------------------------------------
110 logical pure function space_has_mixed_periodicity(this)
111 class(space_t), intent(in) :: this
112
113 space_has_mixed_periodicity = this%periodic_dim > 0 .and. this%periodic_dim < this%dim
115 end function space_has_mixed_periodicity
116
117 !--------------------------------------------------------------
118 subroutine space_write_info(this, namespace)
119 class(space_t), intent(in) :: this
120 type(namespace_t), intent(in) :: namespace
121
122 push_sub(space_write_info)
123
124 call messages_print_with_emphasis(msg="Space", namespace=namespace)
125
126 write(message(1), '(a,i1,a)') 'Octopus will run in ', this%dim, ' dimension(s).'
127 write(message(2), '(a,i1,a)') 'Octopus will treat the system as periodic in ', this%periodic_dim, ' dimension(s).'
128 call messages_info(2, namespace=namespace)
129
130 call messages_print_with_emphasis(namespace=namespace)
131
133 end subroutine space_write_info
134
135 !--------------------------------------------------------------
136 character(len=40) function space_short_info(this) result(info)
137 class(space_t), intent(in) :: this
140
141 write(info, '(a,i1,a,i1)') 'Dimensions = ', this%dim, '; PeriodicDimensions = ', this%periodic_dim
142
143 pop_sub(space_short_info)
144 end function space_short_info
145
146end module space_oct_m
147
148!! Local Variables:
149!! mode: f90
150!! coding: utf-8
151!! End:
subroutine info()
Definition: em_resp.F90:1096
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:723
type(space_t) function space_constructor(namespace)
Definition: space.F90:150
logical pure function space_is_periodic(this)
Definition: space.F90:196
subroutine space_write_info(this, namespace)
Definition: space.F90:212
logical pure function space_has_mixed_periodicity(this)
Definition: space.F90:204
character(len=40) function space_short_info(this)
Definition: space.F90:230