kim-api  2.1.2+v2.1.2.GNU
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
kim_model_refresh_module.f90
Go to the documentation of this file.
1 !
2 ! CDDL HEADER START
3 !
4 ! The contents of this file are subject to the terms of the Common Development
5 ! and Distribution License Version 1.0 (the "License").
6 !
7 ! You can obtain a copy of the license at
8 ! http://www.opensource.org/licenses/CDDL-1.0. See the License for the
9 ! specific language governing permissions and limitations under the License.
10 !
11 ! When distributing Covered Code, include this CDDL HEADER in each file and
12 ! include the License file in a prominent location with the name LICENSE.CDDL.
13 ! If applicable, add the following below this CDDL HEADER, with the fields
14 ! enclosed by brackets "[]" replaced with your own identifying information:
15 !
16 ! Portions Copyright (c) [yyyy] [name of copyright owner]. All rights reserved.
17 !
18 ! CDDL HEADER END
19 !
20 
21 !
22 ! Copyright (c) 2016--2019, Regents of the University of Minnesota.
23 ! All rights reserved.
24 !
25 ! Contributors:
26 ! Ryan S. Elliott
27 !
28 
29 !
30 ! Release: This file is part of the kim-api-2.1.2 package.
31 !
32 
33 
40  use, intrinsic :: iso_c_binding
41  implicit none
42  private
43 
44  public &
45  ! Derived types
46  kim_model_refresh_handle_type, &
47 
48  ! Constants
50 
51  ! Routines
52  operator (.eq.), &
53  operator (.ne.), &
54  kim_set_influence_distance_pointer, &
55  kim_set_neighbor_list_pointers, &
56  kim_get_model_buffer_pointer, &
57  kim_log_entry, &
58  kim_to_string
59 
60 
66  type, bind(c) :: kim_model_refresh_handle_type
67  type(c_ptr) :: p = c_null_ptr
68  end type kim_model_refresh_handle_type
69 
73  type(kim_model_refresh_handle_type), protected, save &
75 
79  interface operator (.eq.)
80  module procedure kim_model_refresh_handle_equal
81  end interface operator (.eq.)
82 
86  interface operator (.ne.)
87  module procedure kim_model_refresh_handle_not_equal
88  end interface operator (.ne.)
89 
96  interface kim_set_influence_distance_pointer
97  module procedure kim_model_refresh_set_influence_distance_pointer
98  end interface kim_set_influence_distance_pointer
99 
106  interface kim_set_neighbor_list_pointers
108  end interface kim_set_neighbor_list_pointers
109 
116  interface kim_get_model_buffer_pointer
118  end interface kim_get_model_buffer_pointer
119 
125  interface kim_log_entry
126  module procedure kim_model_refresh_log_entry
127  end interface kim_log_entry
128 
134  interface kim_to_string
135  module procedure kim_model_refresh_to_string
136  end interface kim_to_string
137 
138 contains
142  logical recursive function kim_model_refresh_handle_equal(lhs, rhs)
143  implicit none
144  type(kim_model_refresh_handle_type), intent(in) :: lhs
145  type(kim_model_refresh_handle_type), intent(in) :: rhs
146 
147  if ((.not. c_associated(lhs%p) .and. c_associated(rhs%p))) then
148  kim_model_refresh_handle_equal = .true.
149  else
150  kim_model_refresh_handle_equal = c_associated(lhs%p, rhs%p)
151  end if
152  end function kim_model_refresh_handle_equal
153 
157  logical recursive function kim_model_refresh_handle_not_equal(lhs, rhs)
158  implicit none
159  type(kim_model_refresh_handle_type), intent(in) :: lhs
160  type(kim_model_refresh_handle_type), intent(in) :: rhs
161 
162  kim_model_refresh_handle_not_equal = .not. (lhs .eq. rhs)
163  end function kim_model_refresh_handle_not_equal
164 
171  recursive subroutine kim_model_refresh_set_influence_distance_pointer( &
172  model_refresh_handle, influence_distance)
173  use kim_interoperable_types_module, only : kim_model_refresh_type
174  implicit none
175  interface
176  recursive subroutine set_influence_distance_pointer(model_refresh, &
177  influence_distance) &
178  bind(c, name="KIM_ModelRefresh_SetInfluenceDistancePointer")
179  use, intrinsic :: iso_c_binding
180  use kim_interoperable_types_module, only : kim_model_refresh_type
181  implicit none
182  type(kim_model_refresh_type), intent(in) :: &
183  model_refresh
184  type(c_ptr), intent(in), value :: influence_distance
185  end subroutine set_influence_distance_pointer
186  end interface
187  type(kim_model_refresh_handle_type), intent(in) :: model_refresh_handle
188  real(c_double), intent(in), target :: influence_distance
189  type(kim_model_refresh_type), pointer :: model_refresh
190 
191  call c_f_pointer(model_refresh_handle%p, model_refresh)
192  call set_influence_distance_pointer(model_refresh, &
193  c_loc(influence_distance))
194  end subroutine kim_model_refresh_set_influence_distance_pointer
195 
202  recursive subroutine kim_model_refresh_set_neighbor_list_pointers( &
203  model_refresh_handle, number_of_neighbor_lists, cutoffs, &
204  modelWillNotRequestNeighborsOfNoncontributingParticles)
205  use kim_interoperable_types_module, only : kim_model_refresh_type
206  implicit none
207  interface
208  recursive subroutine set_neighbor_list_pointers(model_refresh, &
209  number_of_neighbor_lists, cutoffs_ptr, &
210  modelWillNotRequestNeighborsOfNoncontributingParticles) &
211  bind(c, name="KIM_ModelRefresh_SetNeighborListPointers")
212  use, intrinsic :: iso_c_binding
213  use kim_interoperable_types_module, only : kim_model_refresh_type
214  implicit none
215  type(kim_model_refresh_type), intent(in) :: &
216  model_refresh
217  integer(c_int), intent(in), value :: number_of_neighbor_lists
218  type(c_ptr), intent(in), value :: cutoffs_ptr
219  type(c_ptr), intent(in), value :: &
220  modelWillNotRequestNeighborsOfNoncontributingParticles
221  end subroutine set_neighbor_list_pointers
222  end interface
223  type(kim_model_refresh_handle_type), intent(in) :: model_refresh_handle
224  integer(c_int), intent(in) :: number_of_neighbor_lists
225  real(c_double), intent(in), target :: cutoffs(number_of_neighbor_lists)
226  integer(c_int), intent(in), target :: &
227  modelWillNotRequestNeighborsOfNoncontributingParticles( &
228  number_of_neighbor_lists)
229  type(kim_model_refresh_type), pointer :: model_refresh
230 
231  call c_f_pointer(model_refresh_handle%p, model_refresh)
232  call set_neighbor_list_pointers(model_refresh, number_of_neighbor_lists, &
233  c_loc(cutoffs), &
234  c_loc(modelwillnotrequestneighborsofnoncontributingparticles))
236 
243  recursive subroutine kim_model_refresh_get_model_buffer_pointer( &
244  model_refresh_handle, ptr)
245  use kim_interoperable_types_module, only : kim_model_refresh_type
246  implicit none
247  interface
248  recursive subroutine get_model_buffer_pointer(model_refresh, ptr) &
249  bind(c, name="KIM_ModelRefresh_GetModelBufferPointer")
250  use, intrinsic :: iso_c_binding
251  use kim_interoperable_types_module, only : kim_model_refresh_type
252  implicit none
253  type(kim_model_refresh_type), intent(in) :: &
254  model_refresh
255  type(c_ptr), intent(out) :: ptr
256  end subroutine get_model_buffer_pointer
257  end interface
258  type(kim_model_refresh_handle_type), intent(in) :: model_refresh_handle
259  type(c_ptr), intent(out) :: ptr
260  type(kim_model_refresh_type), pointer :: model_refresh
261 
262  call c_f_pointer(model_refresh_handle%p, model_refresh)
263  call get_model_buffer_pointer(model_refresh, ptr)
265 
271  recursive subroutine kim_model_refresh_log_entry(model_refresh_handle, &
272  log_verbosity, message)
273  use kim_log_verbosity_module, only : kim_log_verbosity_type
274  use kim_interoperable_types_module, only : kim_model_refresh_type
275  implicit none
276  interface
277  recursive subroutine log_entry(model_refresh, log_verbosity, message, &
278  line_number, file_name) bind(c, name="KIM_ModelRefresh_LogEntry")
279  use, intrinsic :: iso_c_binding
280  use kim_log_verbosity_module, only : kim_log_verbosity_type
281  use kim_interoperable_types_module, only : kim_model_refresh_type
282  implicit none
283  type(kim_model_refresh_type), intent(in) :: &
284  model_refresh
285  type(kim_log_verbosity_type), intent(in), value :: log_verbosity
286  character(c_char), intent(in) :: message(*)
287  integer(c_int), intent(in), value :: line_number
288  character(c_char), intent(in) :: file_name(*)
289  end subroutine log_entry
290  end interface
291  type(kim_model_refresh_handle_type), intent(in) :: model_refresh_handle
292  type(kim_log_verbosity_type), intent(in) :: log_verbosity
293  character(len=*, kind=c_char), intent(in) :: message
294  type(kim_model_refresh_type), pointer :: model_refresh
295 
296  call c_f_pointer(model_refresh_handle%p, model_refresh)
297  call log_entry(model_refresh, log_verbosity, trim(message)//c_null_char, &
298  0, ""//c_null_char)
299  end subroutine kim_model_refresh_log_entry
300 
306  recursive subroutine kim_model_refresh_to_string(model_refresh_handle, string)
307  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
308  use kim_interoperable_types_module, only : kim_model_refresh_type
309  implicit none
310  interface
311  type(c_ptr) recursive function model_refresh_string(model_refresh) &
312  bind(c, name="KIM_ModelRefresh_ToString")
313  use, intrinsic :: iso_c_binding
314  use kim_interoperable_types_module, only : kim_model_refresh_type
315  implicit none
316  type(kim_model_refresh_type), intent(in) :: &
317  model_refresh
318  end function model_refresh_string
319  end interface
320  type(kim_model_refresh_handle_type), intent(in) :: model_refresh_handle
321  character(len=*, kind=c_char), intent(out) :: string
322  type(kim_model_refresh_type), pointer :: model_refresh
323 
324  type(c_ptr) :: p
325 
326  call c_f_pointer(model_refresh_handle%p, model_refresh)
327  p = model_refresh_string(model_refresh)
328  call kim_convert_c_char_ptr_to_string(p, string)
329  end subroutine kim_model_refresh_to_string
330 end module kim_model_refresh_module
recursive subroutine kim_model_refresh_log_entry(model_refresh_handle, log_verbosity, message)
Write a log entry into the log file.
recursive subroutine kim_model_refresh_set_neighbor_list_pointers(model_refresh_handle, number_of_neighbor_lists, cutoffs, modelWillNotRequestNeighborsOfNoncontributingParticles)
Set the Model's neighbor list data pointers.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::R...
recursive subroutine kim_model_refresh_to_string(model_refresh_handle, string)
Get a string representing the internal state of the Model object.
recursive subroutine kim_model_refresh_get_model_buffer_pointer(model_refresh_handle, ptr)
Get the Model's buffer pointer within the Model object.
type(kim_model_refresh_handle_type), save, public, protected kim_model_refresh_null_handle
NULL handle for use in comparisons.
An Extensible Enumeration for the LogVerbosity's supported by the KIM API.