KIM API V2
kim_model_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--2018, 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-v2.0.0-alpha.0 package.
31 !
32 
33 
35  use, intrinsic :: iso_c_binding
37  implicit none
38  private
39 
40  public &
41  kim_model_handle_type, &
43  operator (.eq.), &
44  operator (.ne.), &
47  kim_model_get_influence_distance, &
48  kim_model_get_number_of_neighbor_list_cutoffs, &
49  kim_model_get_neighbor_list_cutoffs, &
50  kim_model_get_argument_support_status, &
53  kim_model_set_argument_pointer, &
56  kim_model_clear_influence_dist_and_cutoffs_then_refresh_model, &
57  kim_model_get_species_support_and_code, &
59  kim_model_get_parameter_data_type_extent_and_description, &
60  kim_model_get_parameter, &
61  kim_model_set_parameter, &
63  kim_model_get_simulator_buffer_pointer, &
64  kim_model_string, &
65  kim_model_set_log_id, &
66  kim_model_push_log_verbosity, &
68 
69  type, bind(c) :: kim_model_handle_type
70  type(c_ptr) :: p = c_null_ptr
71  end type kim_model_handle_type
72 
73  type(kim_model_handle_type), protected, &
74  bind(c,name="KIM_MODEL_null_handle") &
76 
77  interface operator (.eq.)
78  logical function kim_model_handle_equal(left, right)
79  use, intrinsic :: iso_c_binding
80  import kim_model_handle_type
81  implicit none
82  type(kim_model_handle_type), intent(in) :: left
83  type(kim_model_handle_type), intent(in) :: right
84  end function kim_model_handle_equal
85  end interface operator (.eq.)
86 
87  interface operator (.ne.)
88  logical function kim_model_handle_not_equal(left, right)
89  use, intrinsic :: iso_c_binding
90  import kim_model_handle_type
91  implicit none
92  type(kim_model_handle_type), intent(in) :: left
93  type(kim_model_handle_type), intent(in) :: right
94  end function kim_model_handle_not_equal
95  end interface operator (.ne.)
96 
97  interface kim_model_get_parameter
98  subroutine kim_model_get_parameter_integer(model_handle, parameter_index, &
99  array_index, parameter_value, ierr)
100  use, intrinsic :: iso_c_binding
101  import kim_model_handle_type
102  implicit none
103  type(kim_model_handle_type), intent(in) :: model_handle
104  integer(c_int), intent(in), value :: parameter_index
105  integer(c_int), intent(in), value :: array_index
106  integer(c_int), intent(out) :: parameter_value
107  integer(c_int), intent(out) :: ierr
108  end subroutine kim_model_get_parameter_integer
109 
110  subroutine kim_model_get_parameter_double(model_handle, parameter_index, &
111  array_index, parameter_value, ierr)
112  use, intrinsic :: iso_c_binding
113  import kim_model_handle_type
114  implicit none
115  type(kim_model_handle_type), intent(in) :: model_handle
116  integer(c_int), intent(in), value :: parameter_index
117  integer(c_int), intent(in), value :: array_index
118  real(c_double), intent(out) :: parameter_value
119  integer(c_int), intent(out) :: ierr
120  end subroutine kim_model_get_parameter_double
121  end interface kim_model_get_parameter
122 
123  interface kim_model_set_parameter
124  subroutine kim_model_set_parameter_integer(model_handle, parameter_index, &
125  array_index, parameter_value, ierr)
126  use, intrinsic :: iso_c_binding
127  import kim_model_handle_type
128  implicit none
129  type(kim_model_handle_type), intent(in) :: model_handle
130  integer(c_int), intent(in), value :: parameter_index
131  integer(c_int), intent(in), value :: array_index
132  integer(c_int), intent(in), value :: parameter_value
133  integer(c_int), intent(out) :: ierr
134  end subroutine kim_model_set_parameter_integer
135 
136  subroutine kim_model_set_parameter_double(model_handle, parameter_index, &
137  array_index, parameter_value, ierr)
138  use, intrinsic :: iso_c_binding
139  import kim_model_handle_type
140  implicit none
141  type(kim_model_handle_type), intent(in) :: model_handle
142  integer(c_int), intent(in), value :: parameter_index
143  integer(c_int), intent(in), value :: array_index
144  real(c_double), intent(in), value :: parameter_value
145  integer(c_int), intent(out) :: ierr
146  end subroutine kim_model_set_parameter_double
147  end interface kim_model_set_parameter
148 
149  interface kim_model_set_argument_pointer
150  subroutine kim_model_set_argument_pointer_int0(model_handle, &
151  argument_name, int0, ierr)
152  use, intrinsic :: iso_c_binding
153  use kim_argument_name_module, only : kim_argument_name_type
154  import kim_model_handle_type
155  implicit none
156  type(kim_model_handle_type), intent(in) :: model_handle
157  type(kim_argument_name_type), intent(in), value :: argument_name
158  integer(c_int), intent(in), target :: int0
159  integer(c_int), intent(out) :: ierr
160  end subroutine kim_model_set_argument_pointer_int0
161 
162  subroutine kim_model_set_argument_pointer_int1(model_handle, &
163  argument_name, int1, ierr)
164  use, intrinsic :: iso_c_binding
165  use kim_argument_name_module, only : kim_argument_name_type
166  import kim_model_handle_type
167  implicit none
168  type(kim_model_handle_type), intent(in) :: model_handle
169  type(kim_argument_name_type), intent(in), value :: argument_name
170  integer(c_int), intent(in), target :: int1(:)
171  integer(c_int), intent(out) :: ierr
172  end subroutine kim_model_set_argument_pointer_int1
173 
174  subroutine kim_model_set_argument_pointer_int2(model_handle, &
175  argument_name, int2, ierr)
176  use, intrinsic :: iso_c_binding
177  use kim_argument_name_module, only : kim_argument_name_type
178  import kim_model_handle_type
179  implicit none
180  type(kim_model_handle_type), intent(in) :: model_handle
181  type(kim_argument_name_type), intent(in), value :: argument_name
182  integer(c_int), intent(in), target :: int2(:,:)
183  integer(c_int), intent(out) :: ierr
184  end subroutine kim_model_set_argument_pointer_int2
185 
186  subroutine kim_model_set_argument_pointer_double0(model_handle, &
187  argument_name, double0, ierr)
188  use, intrinsic :: iso_c_binding
189  use kim_argument_name_module, only : &
190  kim_argument_name_type
191  import kim_model_handle_type
192  implicit none
193  type(kim_model_handle_type), intent(in) :: model_handle
194  type(kim_argument_name_type), intent(in), value :: argument_name
195  real(c_double), intent(in), target :: double0
196  integer(c_int), intent(out) :: ierr
197  end subroutine kim_model_set_argument_pointer_double0
198 
199  subroutine kim_model_set_argument_pointer_double1(model_handle, &
200  argument_name, double1, ierr)
201  use, intrinsic :: iso_c_binding
202  use kim_argument_name_module, only : kim_argument_name_type
203  import kim_model_handle_type
204  implicit none
205  type(kim_model_handle_type), intent(in) :: model_handle
206  type(kim_argument_name_type), intent(in), value :: argument_name
207  real(c_double), intent(in), target :: double1(:)
208  integer(c_int), intent(out) :: ierr
209  end subroutine kim_model_set_argument_pointer_double1
210 
211  subroutine kim_model_set_argument_pointer_double2(model_handle, &
212  argument_name, double2, ierr)
213  use, intrinsic :: iso_c_binding
214  use kim_argument_name_module, only : kim_argument_name_type
215  import kim_model_handle_type
216  implicit none
217  type(kim_model_handle_type), intent(in) :: model_handle
218  type(kim_argument_name_type), intent(in), value :: argument_name
219  real(c_double), intent(in), target :: double2(:,:)
220  integer(c_int), intent(out) :: ierr
221  end subroutine kim_model_set_argument_pointer_double2
222  end interface kim_model_set_argument_pointer
223 
224  interface
225  subroutine kim_model_create(numbering, requested_length_unit, &
226  requested_energy_unit, requested_charge_unit, &
227  requested_temperature_unit, requested_time_unit, model_name, &
228  requested_units_accepted, model_handle, ierr)
229  use, intrinsic :: iso_c_binding
230  use kim_numbering_module, only : kim_numbering_type
231  use kim_unit_system_module, only : kim_length_unit_type, &
232  kim_energy_unit_type, kim_charge_unit_type, kim_temperature_unit_type, &
233  kim_time_unit_type
234  import kim_model_handle_type
235  implicit none
236  type(kim_numbering_type), intent(in), value :: numbering
237  type(kim_length_unit_type), intent(in), value :: requested_length_unit
238  type(kim_energy_unit_type), intent(in), value :: requested_energy_unit
239  type(kim_charge_unit_type), intent(in), value :: requested_charge_unit
240  type(kim_temperature_unit_type), intent(in), value :: &
241  requested_temperature_unit
242  type(kim_time_unit_type), intent(in), value :: requested_time_unit
243  character(len=*), intent(in) :: model_name
244  type(kim_model_handle_type), intent(out) :: model_handle
245  integer(c_int), intent(out) :: requested_units_accepted
246  integer(c_int), intent(out) :: ierr
247  end subroutine kim_model_create
248 
249  subroutine kim_model_destroy(model_handle)
250  use, intrinsic :: iso_c_binding
251  import kim_model_handle_type
252  implicit none
253  type(kim_model_handle_type), intent(inout) :: model_handle
254  end subroutine kim_model_destroy
255 
256  subroutine kim_model_get_influence_distance(model_handle, &
257  influence_distance)
258  use, intrinsic :: iso_c_binding
259  import kim_model_handle_type
260  implicit none
261  type(kim_model_handle_type), intent(in) :: model_handle
262  real(c_double), intent(out) :: influence_distance
263  end subroutine kim_model_get_influence_distance
264 
265  subroutine kim_model_get_number_of_neighbor_list_cutoffs(model_handle, &
266  number_of_cutoffs)
267  use, intrinsic :: iso_c_binding
268  import kim_model_handle_type
269  implicit none
270  type(kim_model_handle_type), intent(in) :: model_handle
271  integer(c_int), intent(out) :: number_of_cutoffs
272  end subroutine kim_model_get_number_of_neighbor_list_cutoffs
273 
274  subroutine kim_model_get_neighbor_list_cutoffs(model_handle, cutoffs, ierr)
275  use, intrinsic :: iso_c_binding
276  import kim_model_handle_type
277  implicit none
278  type(kim_model_handle_type), intent(in) :: model_handle
279  real(c_double), intent(out) :: cutoffs(:)
280  integer(c_int), intent(out) :: ierr
281  end subroutine kim_model_get_neighbor_list_cutoffs
282 
283  subroutine kim_model_get_argument_support_status(model_handle, &
284  argument_name, support_status, ierr)
285  use, intrinsic :: iso_c_binding
286  use kim_argument_name_module, only : kim_argument_name_type
287  use kim_support_status_module, only : kim_support_status_type
288  import kim_model_handle_type
289  implicit none
290  type(kim_model_handle_type), intent(in) :: model_handle
291  type(kim_argument_name_type), intent(in), value :: argument_name
292  type(kim_support_status_type), intent(out) :: support_status
293  integer(c_int), intent(out) :: ierr
294  end subroutine kim_model_get_argument_support_status
295 
296  subroutine kim_model_get_callback_support_status(model_handle, &
297  callback_name, support_status, ierr)
298  use, intrinsic :: iso_c_binding
299  use kim_callback_name_module, only : kim_callback_name_type
300  use kim_support_status_module, only : kim_support_status_type
301  import kim_model_handle_type
302  implicit none
303  type(kim_model_handle_type), intent(in) :: model_handle
304  type(kim_callback_name_type), intent(in), value :: callback_name
305  type(kim_support_status_type), intent(out) :: support_status
306  integer(c_int), intent(out) :: ierr
308 
309  subroutine kim_model_set_callback_pointer(model_handle, callback_name, &
310  language_name, fptr, data_object, ierr)
311  use, intrinsic :: iso_c_binding
312  use kim_callback_name_module, only : kim_callback_name_type
313  use kim_language_name_module, only : kim_language_name_type
314  import kim_model_handle_type
315  implicit none
316  type(kim_model_handle_type), intent(in) :: model_handle
317  type(kim_callback_name_type), intent(in), value :: callback_name
318  type(kim_language_name_type), intent(in), value :: language_name
319  type(c_funptr), intent(in), value :: fptr
320  type(c_ptr), intent(in), value :: data_object
321  integer(c_int), intent(out) :: ierr
322  end subroutine kim_model_set_callback_pointer
323 
324  subroutine kim_model_get_units(model_handle, length_unit, energy_unit, &
325  charge_unit, temperature_unit, time_unit)
326  use, intrinsic :: iso_c_binding
327  use kim_unit_system_module, only : kim_length_unit_type, &
328  kim_energy_unit_type, kim_charge_unit_type, kim_temperature_unit_type, &
329  kim_time_unit_type
330  import kim_model_handle_type
331  type(kim_model_handle_type), intent(in) :: model_handle
332  type(kim_length_unit_type), intent(out) :: length_unit
333  type(kim_energy_unit_type), intent(out) :: energy_unit
334  type(kim_charge_unit_type), intent(out) :: charge_unit
335  type(kim_temperature_unit_type), intent(out) :: temperature_unit
336  type(kim_time_unit_type), intent(out) :: time_unit
337  end subroutine kim_model_get_units
338 
339  subroutine kim_model_compute(model_handle, ierr)
340  use, intrinsic :: iso_c_binding
341  import kim_model_handle_type
342  implicit none
343  type(kim_model_handle_type), intent(in) :: model_handle
344  integer(c_int), intent(out) :: ierr
345  end subroutine kim_model_compute
346 
347  subroutine kim_model_clear_influence_dist_and_cutoffs_then_refresh_model( &
348  model_handle, ierr)
349  use, intrinsic :: iso_c_binding
350  import kim_model_handle_type
351  implicit none
352  type(kim_model_handle_type), intent(in) :: model_handle
353  integer(c_int), intent(out) :: ierr
354  end subroutine kim_model_clear_influence_dist_and_cutoffs_then_refresh_model
355 
356  subroutine kim_model_get_species_support_and_code(model_handle, &
357  species_name, species_is_supported, code, ierr)
358  use, intrinsic :: iso_c_binding
359  use kim_species_name_module, only : kim_species_name_type
360  import kim_model_handle_type
361  implicit none
362  type(kim_model_handle_type), intent(in) :: model_handle
363  type(kim_species_name_type), intent(in), value :: species_name
364  integer(c_int), intent(out) :: species_is_supported
365  integer(c_int), intent(out) :: code
366  integer(c_int), intent(out) :: ierr
367  end subroutine kim_model_get_species_support_and_code
368 
369  subroutine kim_model_get_number_of_parameters(model_handle, &
370  number_of_parameters)
371  use, intrinsic :: iso_c_binding
372  import kim_model_handle_type
373  implicit none
374  type(kim_model_handle_type), intent(in) :: model_handle
375  integer(c_int), intent(out) :: number_of_parameters
377 
378  subroutine kim_model_get_parameter_data_type_extent_and_description( &
379  model_handle, index, data_type, extent, description, ierr)
380  use, intrinsic :: iso_c_binding
381  use :: kim_data_type_module, only : kim_data_type_type
382  import kim_model_handle_type
383  implicit none
384  type(kim_model_handle_type), intent(in) :: model_handle
385  integer(c_int), intent(in), value :: index
386  type(kim_data_type_type), intent(out) :: data_type
387  integer(c_int), intent(out) :: extent
388  character(len=*), intent(out) :: description
389  integer(c_int), intent(out) :: ierr
390  end subroutine kim_model_get_parameter_data_type_extent_and_description
391 
392  subroutine kim_model_set_simulator_buffer_pointer(model_handle, ptr)
393  use, intrinsic :: iso_c_binding
394  import kim_model_handle_type
395  implicit none
396  type(kim_model_handle_type), intent(in) :: model_handle
397  type(c_ptr), intent(in), value :: ptr
399 
400  subroutine kim_model_get_simulator_buffer_pointer(model_handle, ptr)
401  use, intrinsic :: iso_c_binding
402  import kim_model_handle_type
403  implicit none
404  type(kim_model_handle_type), intent(in) :: model_handle
405  type(c_ptr), intent(out) :: ptr
406  end subroutine kim_model_get_simulator_buffer_pointer
407 
408  subroutine kim_model_string(model_handle, string)
409  use, intrinsic :: iso_c_binding
410  import kim_model_handle_type
411  implicit none
412  type(kim_model_handle_type), intent(in) :: model_handle
413  character(len=*), intent(out) :: string
414  end subroutine kim_model_string
415 
416  subroutine kim_model_set_log_id(model_handle, log_id)
417  use, intrinsic :: iso_c_binding
418  import kim_model_handle_type
419  implicit none
420  type(kim_model_handle_type), intent(in) :: model_handle
421  character(len=*), intent(in) :: log_id
422  end subroutine kim_model_set_log_id
423 
424  subroutine kim_model_push_log_verbosity(model_handle, log_verbosity)
425  use, intrinsic :: iso_c_binding
426  use kim_log_verbosity_module, only : kim_log_verbosity_type
427  import kim_model_handle_type
428  implicit none
429  type(kim_model_handle_type), intent(in) :: model_handle
430  type(kim_log_verbosity_type), intent(in) :: log_verbosity
431  end subroutine kim_model_push_log_verbosity
432 
433  subroutine kim_model_pop_log_verbosity(model_handle)
434  use, intrinsic :: iso_c_binding
435  use kim_log_verbosity_module, only : kim_log_verbosity_type
436  import kim_model_handle_type
437  implicit none
438  type(kim_model_handle_type), intent(in) :: model_handle
439  end subroutine kim_model_pop_log_verbosity
440  end interface
441 end module kim_model_module
type(kim_model_handle_type), public, protected kim_model_null_handle