Convert a real number to a string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | a | Time span in seconds | 
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
	elemental function realToTime(a) result(o)
		!! Convert a real number to a string
		real(wp),intent(in)::a
			!! Time span in seconds
		character(:),allocatable::o
		
		integer::d,r,h,m,s,t
		character(:),allocatable::tc
		
		r = floor(a)
		
		d = r/(3600*24)
		r = mod(r,3600*24)
		
		h = r/3600
		r = mod(r,3600)
		
		m = r/60
		r = mod(r,60)
		
		s = r
		
		o = ''
		if(d>0) o = o//intToChar(d)//'d '
		if(h>0.or.d>0) o = o//intToChar(h)//'h '
		if(m>0.or.h>0.or.d>0) o = o//intToChar(m)//'m '
		o = o//intToChar(s)
		
		if(d==0 .and. h==0 .and. m==0) then
			t  = floor(1000.0_wp*(a-real(s,wp)))
			tc = intToChar(t)
			tc = repeat('0',3-len(tc))//tc
			o = o//'.'//tc
		end if
		
		o = o//'s'
	end function realToTime