Octopus
states_abst.F90
Go to the documentation of this file.
1!! Copyright (C) 2019 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 st program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18#include "global.h"
19
21 use debug_oct_m
22 use global_oct_m
25 use types_oct_m
27
28 implicit none
29
30 private
31
32 public :: &
37
43 type, abstract :: states_abst_t
44 private
45 type(type_t), public :: wfs_type
46 integer, public :: nst
47 logical, public :: packed
48
49 contains
50
51 procedure(nullify), deferred :: nullify
52 procedure(pack), deferred :: pack
53 procedure(unpack), deferred :: unpack
54 procedure(write_info), deferred :: write_info
55 procedure(set_zero), deferred :: set_zero
56 procedure, non_overridable :: are_packed
57 procedure, non_overridable :: get_type
58 end type states_abst_t
59
60 abstract interface
61 subroutine nullify(st)
62 import states_abst_t
63 class(states_abst_t), intent(inout) :: st
64 end subroutine nullify
65
66 subroutine set_zero(st)
67 import states_abst_t
68 class(states_abst_t), intent(inout) :: st
69 end subroutine set_zero
70
71 subroutine write_info(st, namespace)
72 import states_abst_t
73 import namespace_t
74 class(states_abst_t), intent(in) :: st
75 type(namespace_t), intent(in) :: namespace
76 end subroutine write_info
77
78 subroutine pack(st, copy)
79 import states_abst_t
80 class(states_abst_t), intent(inout) :: st
81 logical, optional, intent(in) :: copy
82 end subroutine pack
83
84 subroutine unpack(st, copy)
85 import states_abst_t
86 class(states_abst_t), intent(inout) :: st
87 logical, optional, intent(in) :: copy
88 end subroutine unpack
89 end interface
90
91contains
92
93 ! ---------------------------------------------------------
94 subroutine states_set_complex(st)
95 class(states_abst_t), intent(inout) :: st
96
97 push_sub(states_set_complex)
98
99 st%wfs_type = type_cmplx
100
101 pop_sub(states_set_complex)
102 end subroutine states_set_complex
103
104 ! ---------------------------------------------------------
105 pure logical function states_are_complex(st) result (wac)
106 class(states_abst_t), intent(in) :: st
107
108 wac = (st%wfs_type == type_cmplx)
109
110 end function states_are_complex
111
112
113 ! ---------------------------------------------------------
114 pure logical function states_are_real(st) result (war)
115 class(states_abst_t), intent(in) :: st
116
117 war = (st%wfs_type == type_float)
118
119 end function states_are_real
120
121 ! -----------------------------------------------------------
122
123 logical pure function are_packed(st) result(packed)
124 class(states_abst_t), intent(in) :: st
125
126 packed = st%packed
127 end function are_packed
128
129 pure type(type_t) function get_type(st) result(res)
130 class(states_abst_t), intent(in) :: st
131
132 res = st%wfs_type
133 end function get_type
134
135
137
139!! Local Variables:
140!! mode: f90
141!! coding: utf-8
142!! End:
subroutine, public states_set_complex(st)
pure logical function, public states_are_complex(st)
logical pure function are_packed(st)
pure logical function, public states_are_real(st)
pure type(type_t) function get_type(st)
type(type_t), public type_float
Definition: types.F90:133
type(type_t), public type_cmplx
Definition: types.F90:134
abstract class for states