kim-api  2.1.4-git+v2.1.3-git-1-g7847914a.GNU
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
kim_log_verbosity_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.git repository.
31 !
32 
33 
40  use, intrinsic :: iso_c_binding
41  implicit none
42  private
43 
44  public &
45  ! Derived types
46  kim_log_verbosity_type, &
47 
48  ! Constants
55 
56  ! Routines
57  kim_known, &
58  operator (.lt.), &
59  operator (.gt.), &
60  operator (.le.), &
61  operator (.ge.), &
62  operator (.eq.), &
63  operator (.ne.), &
64  kim_from_string, &
65  kim_to_string, &
68 
69 
75  type, bind(c) :: kim_log_verbosity_type
81  integer(c_int) :: log_verbosity_id
82  end type kim_log_verbosity_type
83 
89  type(kim_log_verbosity_type), protected, save, &
90  bind(c, name="KIM_LOG_VERBOSITY_silent") &
92 
98  type(kim_log_verbosity_type), protected, save, &
99  bind(c, name="KIM_LOG_VERBOSITY_fatal") &
101 
107  type(kim_log_verbosity_type), protected, save, &
108  bind(c, name="KIM_LOG_VERBOSITY_error") &
110 
116  type(kim_log_verbosity_type), protected, save, &
117  bind(c, name="KIM_LOG_VERBOSITY_warning") &
119 
125  type(kim_log_verbosity_type), protected, save, &
126  bind(c, name="KIM_LOG_VERBOSITY_information") &
128 
134  type(kim_log_verbosity_type), protected, save, &
135  bind(c, name="KIM_LOG_VERBOSITY_debug") &
137 
143  interface kim_known
144  module procedure kim_log_verbosity_known
145  end interface kim_known
146 
152  interface operator (.lt.)
153  module procedure kim_log_verbosity_less_than
154  end interface operator (.lt.)
155 
161  interface operator (.gt.)
162  module procedure kim_log_verbosity_greater_than
163  end interface operator (.gt.)
164 
170  interface operator (.le.)
171  module procedure kim_log_verbosity_less_than_equal
172  end interface operator (.le.)
173 
179  interface operator (.ge.)
180  module procedure kim_log_verbosity_greater_than_equal
181  end interface operator (.ge.)
182 
188  interface operator (.eq.)
189  module procedure kim_log_verbosity_equal
190  end interface operator (.eq.)
191 
197  interface operator (.ne.)
198  module procedure kim_log_verbosity_not_equal
199  end interface operator (.ne.)
200 
207  interface kim_from_string
208  module procedure kim_log_verbosity_from_string
209  end interface kim_from_string
210 
216  interface kim_to_string
217  module procedure kim_log_verbosity_to_string
218  end interface kim_to_string
219 
220 contains
226  logical recursive function kim_log_verbosity_known(log_verbosity)
227  implicit none
228  interface
229  integer(c_int) recursive function known(log_verbosity) &
230  bind(c, name="KIM_LogVerbosity_Known")
231  use, intrinsic :: iso_c_binding
232  import kim_log_verbosity_type
233  implicit none
234  type(kim_log_verbosity_type), intent(in), value :: log_verbosity
235  end function known
236  end interface
237  type(kim_log_verbosity_type), intent(in) :: log_verbosity
238 
239  kim_log_verbosity_known = (known(log_verbosity) /= 0)
240  end function kim_log_verbosity_known
241 
247  logical recursive function kim_log_verbosity_less_than(lhs, rhs)
248  implicit none
249  type(kim_log_verbosity_type), intent(in) :: lhs
250  type(kim_log_verbosity_type), intent(in) :: rhs
251 
252  kim_log_verbosity_less_than &
253  = (lhs%log_verbosity_id .lt. rhs%log_verbosity_id)
254  end function kim_log_verbosity_less_than
255 
261  logical recursive function kim_log_verbosity_greater_than(lhs, rhs)
262  implicit none
263  type(kim_log_verbosity_type), intent(in) :: lhs
264  type(kim_log_verbosity_type), intent(in) :: rhs
265 
266  kim_log_verbosity_greater_than &
267  = (lhs%log_verbosity_id .ge. rhs%log_verbosity_id)
268  end function kim_log_verbosity_greater_than
269 
275  logical recursive function kim_log_verbosity_less_than_equal(lhs, rhs)
276  implicit none
277  type(kim_log_verbosity_type), intent(in) :: lhs
278  type(kim_log_verbosity_type), intent(in) :: rhs
279 
280  kim_log_verbosity_less_than_equal &
281  = (lhs%log_verbosity_id .le. rhs%log_verbosity_id)
282  end function kim_log_verbosity_less_than_equal
283 
289  logical recursive function kim_log_verbosity_greater_than_equal(lhs, rhs)
290  implicit none
291  type(kim_log_verbosity_type), intent(in) :: lhs
292  type(kim_log_verbosity_type), intent(in) :: rhs
293 
294  kim_log_verbosity_greater_than_equal &
295  = (lhs%log_verbosity_id .ge. rhs%log_verbosity_id)
296  end function kim_log_verbosity_greater_than_equal
297 
303  logical recursive function kim_log_verbosity_equal(lhs, rhs)
304  implicit none
305  type(kim_log_verbosity_type), intent(in) :: lhs
306  type(kim_log_verbosity_type), intent(in) :: rhs
307 
308  kim_log_verbosity_equal &
309  = (lhs%log_verbosity_id .eq. rhs%log_verbosity_id)
310  end function kim_log_verbosity_equal
311 
317  logical recursive function kim_log_verbosity_not_equal(lhs, rhs)
318  implicit none
319  type(kim_log_verbosity_type), intent(in) :: lhs
320  type(kim_log_verbosity_type), intent(in) :: rhs
321 
322  kim_log_verbosity_not_equal = .not. (lhs .eq. rhs)
323  end function kim_log_verbosity_not_equal
324 
331  recursive subroutine kim_log_verbosity_from_string(string, log_verbosity)
332  implicit none
333  interface
334  type(kim_log_verbosity_type) recursive function from_string(string) &
335  bind(c, name="KIM_LogVerbosity_FromString")
336  use, intrinsic :: iso_c_binding
337  import kim_log_verbosity_type
338  implicit none
339  character(c_char), intent(in) :: string(*)
340  end function from_string
341  end interface
342  character(len=*, kind=c_char), intent(in) :: string
343  type(kim_log_verbosity_type), intent(out) :: log_verbosity
344 
345  log_verbosity = from_string(trim(string)//c_null_char)
346  end subroutine kim_log_verbosity_from_string
347 
353  recursive subroutine kim_log_verbosity_to_string(log_verbosity, string)
354  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
355  implicit none
356  interface
357  type(c_ptr) recursive function get_string(log_verbosity) &
358  bind(c, name="KIM_LogVerbosity_ToString")
359  use, intrinsic :: iso_c_binding
360  import kim_log_verbosity_type
361  implicit none
362  type(kim_log_verbosity_type), intent(in), value :: log_verbosity
363  end function get_string
364  end interface
365  type(kim_log_verbosity_type), intent(in) :: log_verbosity
366  character(len=*, kind=c_char), intent(out) :: string
367 
368  type(c_ptr) :: p
369 
370  p = get_string(log_verbosity)
371  call kim_convert_c_char_ptr_to_string(p, string)
372  end subroutine kim_log_verbosity_to_string
373 
380  recursive subroutine kim_get_number_of_log_verbosities( &
381  number_of_log_verbosities)
382  implicit none
383  interface
384  recursive subroutine get_number_of_log_verbosities( &
385  number_of_log_verbosities) &
386  bind(c, name="KIM_LOG_VERBOSITY_GetNumberOfLogVerbosities")
387  use, intrinsic :: iso_c_binding
388  implicit none
389  integer(c_int), intent(out) :: number_of_log_verbosities
390  end subroutine get_number_of_log_verbosities
391  end interface
392  integer(c_int), intent(out) :: number_of_log_verbosities
393 
394  call get_number_of_log_verbosities(number_of_log_verbosities)
395  end subroutine kim_get_number_of_log_verbosities
396 
402  recursive subroutine kim_get_log_verbosity(index, log_verbosity, ierr)
403  implicit none
404  interface
405  integer(c_int) recursive function get_log_verbosity(index, &
406  log_verbosity) bind(c, name="KIM_LOG_VERBOSITY_GetLogVerbosity")
407  use, intrinsic :: iso_c_binding
408  import kim_log_verbosity_type
409  implicit none
410  integer(c_int), intent(in), value :: index
411  type(kim_log_verbosity_type), intent(out) :: log_verbosity
412  end function get_log_verbosity
413  end interface
414  integer(c_int), intent(in) :: index
415  type(kim_log_verbosity_type), intent(out) :: log_verbosity
416  integer(c_int), intent(out) :: ierr
417 
418  ierr = get_log_verbosity(index-1, log_verbosity)
419  end subroutine kim_get_log_verbosity
420 end module kim_log_verbosity_module
recursive subroutine, public kim_get_number_of_log_verbosities(number_of_log_verbosities)
Get the number of standard LogVerbosity's defined by the KIM API.
type(kim_log_verbosity_type), save, public, protected kim_log_verbosity_debug
type(kim_log_verbosity_type), save, public, protected kim_log_verbosity_silent
type(kim_log_verbosity_type), save, public, protected kim_log_verbosity_warning
type(kim_log_verbosity_type), save, public, protected kim_log_verbosity_fatal
recursive subroutine, public kim_get_log_verbosity(index, log_verbosity, ierr)
Get the identity of each defined standard LogVerbosity.
type(kim_log_verbosity_type), save, public, protected kim_log_verbosity_error
An Extensible Enumeration for the LogVerbosity's supported by the KIM API.
type(kim_log_verbosity_type), save, public, protected kim_log_verbosity_information