Re: Standards question regarding intrinsics with complex arguments



Paul van Delst wrote:

Compilation of the following test code

PROGRAM test_cmplx
! Double precision
INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(15)

15 digits is about 49.8 bits, which should be double
precision on all IBM machines. It gets more interesting
at 16, which is about 53.12 bits. IBM PL/I compilers
call that double, instead of rounding up to quad, as
one might expect.

! Variables
COMPLEX(dp) :: z
REAL(dp) :: x, y
! Assign a value to the complex number
z = CMPLX(3.14159_dp,-0.12345_dp,dp)
PRINT *, z
! Split out the parts
x = REAL(z,dp); y = AIMAG(z)
PRINT *, x, y
END PROGRAM test_cmplx

on an IBM P6 using the AIX v11.1 xlf95 compiler with the -qlanglvl=95pure switch produces the output:

So that asks for the strict standard interpretation?

v1n3:scratch : xlf95 -qlanglvl=95pure test_cmplx.f90
"test_cmplx.f90", line 13.7: 1518-256 (L) The intrinsic procedure real (with
these arguments) is not permitted by the Fortran 95 standard.
"test_cmplx.f90", line 13.23: 1518-256 (L) The intrinsic procedure aimag (with
these arguments) is not permitted by the Fortran 95 standard.
** test_cmplx === End of Compilation 1 ===
1501-510 Compilation successful for file test_cmplx.f90.

Even though it complained, it still says that the
compilation was successful.

I believe the code in question is standard Fortran95
and that the compiler is incorrect in producing these
> warnings. Section 4.3.1.3 (Complex Types) of the Fortran95
standard states:

"Each approximation method used to represent data entities of
type real shall be available for both the real and imaginary
parts of a data entity of type complex. A kind type parameter
may be specified for a complex entity and selects for both
parts the real approximation method characterized by this kind
type parameter value."

(snip)

An IBM person has since told me that:
<quote>
...I suspect the standard does not require an implementation to support any precision in complex intrinsic functions other than the default. Therefore aimag(z) is only standards compliant if z is a default precision complex number.
</quote>

IBM is usually pretty good at following standards, but I
agree it does look suspicious. Is there an online version
of Fortran 95 (or close)?

-- glen

.


Quantcast