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 ! type_is_complex also covers the single-precision complex type (TYPE_CMPLX_SINGLE)
109 wac = type_is_complex(st%wfs_type)
110
111 end function states_are_complex
112
113
114 ! ---------------------------------------------------------
115 pure logical function states_are_real(st) result (war)
116 class(states_abst_t), intent(in) :: st
117
118 war = (st%wfs_type == type_float .or. st%wfs_type == type_float_single)
119
120 end function states_are_real
121
122 ! -----------------------------------------------------------
123
124 logical pure function are_packed(st) result(packed)
125 class(states_abst_t), intent(in) :: st
126
127 packed = st%packed
128 end function are_packed
129
130 pure type(type_t) function get_type(st) result(res)
131 class(states_abst_t), intent(in) :: st
132
133 res = st%wfs_type
134 end function get_type
135
136
137end module states_abst_oct_m
139
140!! Local Variables:
141!! mode: f90
142!! coding: utf-8
143!! 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), parameter, public type_float_single
Definition: types.F90:141
type(type_t), parameter, public type_cmplx
Definition: types.F90:137
logical pure function, public type_is_complex(this)
Definition: types.F90:185
type(type_t), parameter, public type_float
Definition: types.F90:136
abstract class for states