real2char Function

public elementalfunction real2char(a, f, l) result(o)

Arguments

Type IntentOptional AttributesName
real(kind=wp), intent(in) :: a

Real value to convert

character(len=*), intent(in), optional :: f

Format of result

integer, intent(in), optional :: l

Length of result

Return Value character(len=:), allocatable

Description

Convert a real to a character

Called By

proc~~real2char~~CalledByGraph proc~real2char real2char proc~showprogress showProgress proc~showprogress->proc~real2char
Help

Variables

TypeVisibility AttributesNameInitial
character(len=128), public :: buf

Source Code

	elemental function real2char(a,f,l) result(o)
		!! Convert a real to a character
		real(wp),intent(in)::a
			!! Real value to convert
		character(*),optional,intent(in)::f
			!! Format of result
		integer,optional,intent(in)::l
			!! Length of result
		character(:),allocatable::o
		
		character(128)::buf
		
		if(present(l)) then
			allocate(character(l)::o)
			if(present(f)) then
				write(o,'('//f//')') a
			else
				write(o,*) a
			end if
		else
			if(present(f)) then
				write(buf,'('//f//')') a
			else
				write(buf,*) a
			end if
			o = trim(adjustl(buf))
		end if
	end function real2char