On Jan 6, 11:58 am, "robin" <
robi...@bigpond.com> wrote:
> "jfh" <
john.har...@vuw.ac.nz> wrote in messagenews:a9a03503-11cd-4f7c...@f5g2000yqh.googlegroups.com...
>
> | Recently I found myself wishing there was an intrinsic inquiry
> | function (let's call it maxlistdir(x) ) that would return the maximum
> | length needed to write a list-directed value of the same kind as x,
>
> Of what use would that be?
>
I wrote a module to permit keeping units with variables by defining
type var with components value (real(kind(1d0)) numerical value,
powers (an array of 6 elements giving the powers of
m,kg,s,amp,mol,kelvin) and badch (one character, '.' if no error was
detected, '+' if addition attempted of things with different powers,
similarly '-', and 'L' if log of something that wasn't dimensionless
was attempted). Then I wrote a subroutine with an optional format for
the value, to write such a var to a character variable (string, say),
giving value, powers and an appropriate warning if badch/='.'. If the
format wasn't present the value would be list-directed, and the
problem my suggestion was intended to solve is finding the appropriate
length to declare string with.
John Harper
!
! Type var is (value,powers,badch) where:
! value is a double precision real scalar,
! powers is a single precision array of 6 elements
(m,kg,sec,amp,mol,K),
! badch is one character, not '.' if and only if an error has been
found
! or suspected.