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

Converts data types to real. More...

Private Member Functions

real function, pointer generic_to_real (generic, makecopy)
 Converts a generic to a real. If this is infact an integer then will do a conversion and allocate pointed to this. More...
 
real function string_to_real (string)
 Converts a string to a real. More...
 
real function integer_to_real (input)
 Converts an integer to a real. More...
 
real function logical_to_real (input)
 Converts a logical to a real. More...
 

Detailed Description

Converts data types to real.

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 real
copyflagFor generic data only: Whether to use a copy of the structured data or not
Returns
A real. For generic data a pointer to the real or null if generic conversion not possible

Definition at line 60 of file conversions.F90.

Member Function/Subroutine Documentation

◆ generic_to_real()

real function, pointer conversions_mod::conv_to_real::generic_to_real ( class(*), intent(in), pointer  generic,
logical, intent(in)  makecopy 
)
private

Converts a generic to a real. If this is infact an integer then will do a conversion and allocate pointed to this.

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

Definition at line 434 of file conversions.F90.

435  class(*), pointer, intent(in) :: generic
436  logical, intent(in) :: makecopy
437  real, pointer :: generic_to_real
438 
439  select type(generic)
440  type is (real)
441  if (makecopy) then
442  allocate(generic_to_real, source=generic)
443  else
444  generic_to_real=>generic
445  end if
446  type is (integer)
447  allocate(generic_to_real)
448  generic_to_real=conv_to_real(generic)
449  class default
450  generic_to_real=>null()
451  end select

◆ integer_to_real()

real function conversions_mod::conv_to_real::integer_to_real ( integer, intent(in)  input)
private

Converts an integer to a real.

Parameters
inputThe integer to convert into a real
Returns
The real

Definition at line 470 of file conversions.F90.

471  integer, intent(in) :: input
472 
473  integer_to_real = real(input)

◆ logical_to_real()

real function conversions_mod::conv_to_real::logical_to_real ( logical, intent(in)  input)
private

Converts a logical to a real.

Parameters
inputThe logical to convert into a real
Returns
The real

Definition at line 479 of file conversions.F90.

480  logical, intent(in) :: input
481 
482  if (input) then
483  logical_to_real = 1.0
484  else
485  logical_to_real = 0.0
486  end if

◆ string_to_real()

real function conversions_mod::conv_to_real::string_to_real ( character(len=*), intent(in)  string)
private

Converts a string to a real.

Parameters
stringThe string to convert into a real
Returns
The real

Definition at line 457 of file conversions.F90.

458  character(len=*), intent(in) :: string
459 
460  if (scan(string, "E") .ne. 0 .or. scan(string, "e") .ne. 0) then
461  read(string, '(es30.10)' ) string_to_real
462  else
463  read(string, '(f11.2)' ) string_to_real
464  end if

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