Compare a real value with its true value in string form; return the correct digit count
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | r | Real value |
||
character(len=*), | intent(in) | :: | c | True value |
Correct digits
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.
function checkPrecision(r,c) result(o)
!! Compare a real value with its true value in string form; return the correct digit count
real(wp),intent(in)::r
!! Real value
character(*),intent(in)::c
!! True value
integer::o
!! Correct digits
character(41)::buf
integer::k
write(buf,'(1F41.39)') r
do k=1,len(c)
if(buf(k:k)/=c(k:k)) exit
end do
o = k-2
end function checkPrecision