Octopus
pseudo_set.F90
Go to the documentation of this file.
1!! Copyright (C) 2018 X. Andrade
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the Lesser GNU General Public License as published by
5!! the Free Software Foundation; either version 3, 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
23 use global_oct_m
24 use iso_c_binding
25 use string_oct_m
26
27 implicit none
28
29 private
30
31 public :: &
40
41 !! Dummy data type for pseudopotential sets. The actual data type is a C++ class, defined in set.hpp.
43 type pseudo_set_t
44 private
45 integer(int64) :: dummy
46 end type pseudo_set_t
47
48 interface
49
51 subroutine pseudo_set_nullify(pseudo_set)
52 import :: pseudo_set_t
53 implicit none
54
55 type(pseudo_set_t), intent(inout) :: pseudo_set
56 end subroutine pseudo_set_nullify
57
58 ! -------------------------------------------------
59
61 subroutine pseudo_set_end(pseudo_set)
62 import :: pseudo_set_t
63 implicit none
64
65 type(pseudo_set_t), intent(inout) :: pseudo_set
66 end subroutine pseudo_set_end
67
68 ! -------------------------------------------------
69
70 integer function pseudo_set_lmax(pseudo_set, element)
72 import :: pseudo_set_t
73 implicit none
74
75 type(pseudo_set_t), intent(in) :: pseudo_set
76 type(element_t), intent(in) :: element
77 end function pseudo_set_lmax
78
79 ! -------------------------------------------------
80
81 integer function pseudo_set_llocal(pseudo_set, element)
83 import :: pseudo_set_t
84 implicit none
85
86 type(pseudo_set_t), intent(in) :: pseudo_set
87 type(element_t), intent(in) :: element
88 end function pseudo_set_llocal
89
90 end interface
91
92
93contains
94
95 subroutine pseudo_set_init(pseudo_set, dirname, ierr)
96 type(pseudo_set_t), intent(out) :: pseudo_set
97 character(len=*), intent(in) :: dirname
98 integer, intent(out) :: ierr
99
100 interface
101 subroutine pseudo_set_init_low(pseudo_set, dirname, ierr)
102 use iso_c_binding
103 import :: pseudo_set_t
104 implicit none
105
106 type(pseudo_set_t), intent(out) :: pseudo_set
107 character(kind=c_char), intent(in) :: dirname(*)
108 integer, intent(out) :: ierr
109 end subroutine pseudo_set_init_low
110 end interface
111
112 call pseudo_set_init_low(pseudo_set, string_f_to_c(dirname), ierr)
113
114 end subroutine pseudo_set_init
115
116 ! -----------------------------------------------------------------------
117
118 logical function pseudo_set_has(pseudo_set, element)
119 type(pseudo_set_t), intent(in) :: pseudo_set
120 type(element_t), intent(in) :: element
121
122 interface
123 integer function pseudo_set_has_low(pseudo_set, element)
124 use element_oct_m
125 import :: pseudo_set_t
126 implicit none
127
128 type(pseudo_set_t), intent(in) :: pseudo_set
129 type(element_t), intent(in) :: element
130 end function pseudo_set_has_low
131 end interface
132
133 pseudo_set_has = pseudo_set_has_low(pseudo_set, element) /= 0
134
135 end function pseudo_set_has
136
137 ! -----------------------------------------------------------------
139 character(len=MAX_PATH_LEN) function pseudo_set_file_path(pseudo_set, element)
140 type(pseudo_set_t), intent(in) :: pseudo_set
141 type(element_t), intent(in) :: element
142
143 character(kind=c_char) :: path_c(max_path_len+1)
144
145 interface
146 subroutine pseudo_set_file_path_low(pseudo_set, element, path)
147 use iso_c_binding
148 use element_oct_m
149 import :: pseudo_set_t
150 implicit none
151
152 type(pseudo_set_t), intent(in) :: pseudo_set
153 type(element_t), intent(in) :: element
154 character(kind=c_char), intent(inout) :: path(*)
155 end subroutine pseudo_set_file_path_low
156 end interface
157
158 path_c = c_null_char
159 call pseudo_set_file_path_low(pseudo_set, element, path_c)
161
162 end function pseudo_set_file_path
163
164end module pseudo_set_oct_m
166!! Local Variables:
167!! mode: f90
168!! coding: utf-8
169!! End:
Delete the C++ object.
Definition: pseudo_set.F90:156
Nullify the C++ pointer.
Definition: pseudo_set.F90:146
integer, parameter, public max_path_len
Public types, variables and procedures.
Definition: global.F90:150
subroutine, public pseudo_set_init(pseudo_set, dirname, ierr)
Definition: pseudo_set.F90:191
character(len=max_path_len) function, public pseudo_set_file_path(pseudo_set, element)
Definition: pseudo_set.F90:235
logical function, public pseudo_set_has(pseudo_set, element)
Definition: pseudo_set.F90:214
subroutine, public string_c_to_f(c_string, f_string)
convert a C string to a Fortran string
Definition: string.F90:292
character(kind=c_char, len=1) function, dimension(:), allocatable, public string_f_to_c(f_string)
convert a Fortran string to a C string
Definition: string.F90:273
The integer(int64) dummy reserves the memory for the pointer to the actual data structure.
Definition: pseudo_set.F90:138