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(/=), &
33
34 type type_t
35 private
36 integer :: itype
37 end type type_t
38
39 type(type_t), public :: TYPE_NONE = type_t(0)
40 type(type_t), public :: TYPE_FLOAT = type_t(1)
41 type(type_t), public :: TYPE_CMPLX = type_t(2)
42 type(type_t), public :: TYPE_INTEGER = type_t(3)
43 type(type_t), public :: TYPE_BYTE = type_t(4)
44 type(type_t), public :: TYPE_INTEGER8 = type_t(5)
45
46 interface operator(==)
47 module procedure types_equal
48 end interface operator(==)
49
50 interface operator(/=)
51 module procedure types_not_equal
52 end interface operator(/=)
53
54 integer :: sizes(5) = (/8, 16, 4, 1, 8/)
55
56contains
57
58 integer pure function types_get_size(this) result(size)
59 type(type_t), intent(in) :: this
60
61 size = sizes(this%itype)
62 end function types_get_size
63
64 ! -----------------------------------------------------
65
66 logical pure function types_equal(ta, tb) result(equal)
67 type(type_t), intent(in) :: ta
68 type(type_t), intent(in) :: tb
69
70 equal = ta%itype == tb%itype
71
72 end function types_equal
73
74 ! -----------------------------------------------------
75
76 logical pure function types_not_equal(ta, tb) result(equal)
77 type(type_t), intent(in) :: ta
78 type(type_t), intent(in) :: tb
79
80 equal = ta%itype /= tb%itype
81
82 end function types_not_equal
83
84 ! -----------------------------------------------------
85
86 logical pure function type_is_complex(this) result(is_complex)
87 type(type_t), intent(in) :: this
88
89 is_complex = this == type_cmplx
90
91 end function type_is_complex
92
93end module types_oct_m
94
95!! Local Variables:
96!! mode: f90
97!! coding: utf-8
98!! End:
logical pure function types_equal(ta, tb)
Definition: types.F90:160
type(type_t), public type_cmplx
Definition: types.F90:134
logical pure function types_not_equal(ta, tb)
Definition: types.F90:170
logical pure function, public type_is_complex(this)
Definition: types.F90:180
integer pure function, public types_get_size(this)
Definition: types.F90:152