Octopus
types.F90
Go to the documentation of this file.
1!! Copyright (C) 2010 X. Andrade
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 types_oct_m
22
23 implicit none
24
25 private
26
27 public :: &
28 type_t, &
30 operator(==), &
31 operator(/=), &
34
35 type type_t
36 private
37 integer :: itype = 0
38 end type type_t
39
40 type(type_t), parameter, public :: TYPE_NONE = type_t(0)
41 type(type_t), parameter, public :: TYPE_FLOAT = type_t(1)
42 type(type_t), parameter, public :: TYPE_CMPLX = type_t(2)
43 type(type_t), parameter, public :: TYPE_INTEGER = type_t(3)
44 type(type_t), parameter, public :: TYPE_BYTE = type_t(4)
45 type(type_t), parameter, public :: TYPE_INTEGER8 = type_t(5)
46 type(type_t), parameter, public :: TYPE_FLOAT_SINGLE = type_t(6)
47 type(type_t), parameter, public :: TYPE_CMPLX_SINGLE = type_t(7)
48
49 interface operator(==)
50 module procedure types_equal
51 end interface operator(==)
52
53 interface operator(/=)
54 module procedure types_not_equal
55 end interface operator(/=)
56
57 integer, parameter :: sizes(7) = (/8, 16, 4, 1, 8, 4, 8/)
58
59contains
60
61 integer pure function types_get_size(this) result(size)
62 type(type_t), intent(in) :: this
63
64 size = sizes(this%itype)
65 end function types_get_size
66
67 ! -----------------------------------------------------
68
69 logical pure function types_equal(ta, tb) result(equal)
70 type(type_t), intent(in) :: ta
71 type(type_t), intent(in) :: tb
72
73 equal = ta%itype == tb%itype
74
75 end function types_equal
76
77 ! -----------------------------------------------------
78
79 logical pure function types_not_equal(ta, tb) result(equal)
80 type(type_t), intent(in) :: ta
81 type(type_t), intent(in) :: tb
82
83 equal = ta%itype /= tb%itype
84
85 end function types_not_equal
86
87 ! -----------------------------------------------------
88
89 logical pure function type_is_complex(this) result(is_complex)
90 type(type_t), intent(in) :: this
91
92 is_complex = this == type_cmplx .or. this == type_cmplx_single
93
94 end function type_is_complex
95
96 ! -----------------------------------------------------
97
98 logical pure function type_is_single(this) result(is_single)
99 type(type_t), intent(in) :: this
100
101 is_single = this == type_float_single .or. this == type_cmplx_single
102
103 end function type_is_single
104
105end module types_oct_m
106
107!! Local Variables:
108!! mode: f90
109!! coding: utf-8
110!! End:
type(type_t), parameter, public type_cmplx_single
Definition: types.F90:142
logical pure function types_equal(ta, tb)
Definition: types.F90:165
logical pure function types_not_equal(ta, tb)
Definition: types.F90:175
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
integer pure function, public types_get_size(this)
Definition: types.F90:157
logical pure function, public type_is_single(this)
Definition: types.F90:194