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 58 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 423 of file conversions.F90.

423  class(*), pointer, intent(in) :: generic
424  logical, intent(in) :: makecopy
425  real, pointer :: generic_to_real
426 
427  select type(generic)
428  type is (real)
429  if (makecopy) then
430  allocate(generic_to_real, source=generic)
431  else
432  generic_to_real=>generic
433  end if
434  type is (integer)
435  allocate(generic_to_real)
436  generic_to_real=conv_to_real(generic)
437  class default
438  generic_to_real=>null()
439  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 459 of file conversions.F90.

459  integer, intent(in) :: input
460 
461  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 468 of file conversions.F90.

468  logical, intent(in) :: input
469 
470  if (input) then
471  logical_to_real = 1.0
472  else
473  logical_to_real = 0.0
474  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 446 of file conversions.F90.

446  character(len=*), intent(in) :: string
447 
448  if (scan(string, "E") .ne. 0 .or. scan(string, "e") .ne. 0) then
449  read(string, '(es30.10)' ) string_to_real
450  else
451  read(string, '(f10.0)' ) string_to_real
452  end if

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