This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: libquad question
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Dominique Dhumieres <dominiq at lps dot ens dot fr>
- Cc: fortran at gcc dot gnu dot org, fxcoudert at gmail dot com
- Date: Mon, 6 Sep 2010 08:48:08 -0700
- Subject: Re: libquad question
- References: <20100906122638.BB05F3BE18@mailhost.lps.ens.fr>
On Mon, Sep 06, 2010 at 02:26:38PM +0200, Dominique Dhumieres wrote:
> Steve,
>
> I am not sure to understand your problem.
>
The problem is that on FreeBSD (and any other system)
where precision(1.0_10) and precision(1.0_8) are
the same, the testsuite may not run tests on REAL(10),
because the code typcally uses selected_real_kind()
with the idiom 'precision(1.0_8) + 1'. For example,
see default_format_2.f90.
The only way that I've found to enumerate the available kinds
(with libquad install) is
integer, parameter :: k1 = selected_real_kind(precision(0.0))
integer, parameter :: &
& k2 = max(max(k1, selected_real_kind(p = precision(0.0_k1) + 1)), &
min(k1, selected_real_kind(r = range(0.0_k1) + 1)))
integer, parameter :: &
& k3 = max(min(k2, selected_real_kind(p = precision(0.0_k2) + 1)), &
max(k2, selected_real_kind(r = range(0.0_k2) + 1)))
integer, parameter :: &
& k4 = max(max(k3, selected_real_kind(p = precision(0.0_k3) + 1)), &
min(k3, selected_real_kind(r = range(0.0_k3) + 1)))
real(k1) a
real(k2) b
real(k3) c
real(k4) d
print '(I2,1X,I2,1X,I4)', kind(a), precision(a), range(a)
print '(I2,1X,I2,1X,I4)', kind(b), precision(b), range(b)
print '(I2,1X,I2,1X,I4)', kind(c), precision(c), range(c)
print '(I2,1X,I2,1X,I4)', kind(d), precision(d), range(d)
end
laptop:kargl[208] ./z
4 6 37
8 15 307
10 15 4931
16 33 4931
It is not possible to use either precision() or range() alone
to get all possible kinds.
--
Steve