MONC
Private Member Functions | List of all members
conversions_mod::conv_to_logical Interface Reference

Converts data types to logical. More...

Private Member Functions

logical function, pointer generic_to_logical (generic, makecopy)
 Converts a generic to a logical. More...
 
logical function string_to_logical (string)
 Converts a string to a logical. More...
 
logical function integer_to_logical (input)
 Converts an integer to a logical. More...
 
logical function real_to_logical (input)
 Converts a real to a logical. More...
 

Detailed Description

Converts data types to logical.

For the generic input then a flag indicating whether to make a copy of the underlying generic data or not is required. For all other data this copy is made automatically and no flag is required

Parameters
dataThe data to convert into a logical
copyflagFor generic data only: Whether to use a copy of the structured data or not
Returns
A logical. For generic data a pointer to the logical or null if generic conversion not possible

Definition at line 71 of file conversions.F90.

Member Function/Subroutine Documentation

◆ generic_to_logical()

logical function, pointer conversions_mod::conv_to_logical::generic_to_logical ( class(*), intent(in), pointer  generic,
logical, intent(in)  makecopy 
)
private

Converts a generic to a logical.

Parameters
genericThe generic to convert into a logical
makecopyWhether to use a copy of the generic data or not
Returns
A pointer to the logical or null if generic conversion not possible

Definition at line 352 of file conversions.F90.

353  class(*), pointer, intent(in) :: generic
354  logical, intent(in) :: makecopy
355  logical, pointer :: generic_to_logical
356 
357  select type(generic)
358  type is (logical)
359  if (makecopy) then
360  allocate(generic_to_logical, source=generic)
361  else
362  generic_to_logical=>generic
363  end if
364  class default
365  generic_to_logical=>null()
366  end select

◆ integer_to_logical()

logical function conversions_mod::conv_to_logical::integer_to_logical ( integer, intent(in)  input)
private

Converts an integer to a logical.

Parameters
inputThe integer to convert into a logical
Returns
The logical

Definition at line 386 of file conversions.F90.

387  integer, intent(in) :: input
388 
389  if (input .ge. 1) then
390  integer_to_logical = .true.
391  else
392  integer_to_logical = .false.
393  end if

◆ real_to_logical()

logical function conversions_mod::conv_to_logical::real_to_logical ( real, intent(in)  input)
private

Converts a real to a logical.

Parameters
inputThe real to convert into a logical
Returns
The logical

Definition at line 399 of file conversions.F90.

400  real, intent(in) :: input
401 
402  if (input .ge. 1.0) then
403  real_to_logical = .true.
404  else
405  real_to_logical = .false.
406  end if

◆ string_to_logical()

logical function conversions_mod::conv_to_logical::string_to_logical ( character(len=*), intent(in)  string)
private

Converts a string to a logical.

Parameters
stringThe string to convert into a logical (case sensitive)
Returns
The logical

Definition at line 372 of file conversions.F90.

373  character(len=*), intent(in) :: string
374 
375  if (trim(adjustl(string)) .eq. "true" .or. trim(adjustl(string)) .eq. ".true." .or. &
376  trim(adjustl(string)) .eq. ".true" .or. trim(adjustl(string)) .eq. "true.") then
377  string_to_logical = .true.
378  else
379  string_to_logical = .false.
380  end if

The documentation for this interface was generated from the following file: