Fortran
Asynchronous I/O is now fully supported. The program needs to be linked against the pthreads library to use it, otherwise the I/O is done synchronously. For systems which do not support POSIX condition variables, such as AIX, all I/O is still done synchronously.
The BACK argument for MINLOC and MAXLOC has been implemented.
The FINDLOC intrinsic function has been implemented.
The IS_CONTIGUOUS intrinsic function has been implemented.
Direct access to the real and imaginary parts of a complex variable via c%re and c%im has been implemented.
Type parameter inquiry via str%len and a%kind has been implemented.
C descriptors and the ISO_Fortran_binding.h source file have been implemented.
The MAX and MIN intrinsics are no longer guaranteed to return any particular value in case one of the arguments is a NaN. Note that this conforms to the Fortran standard and to what other Fortran compilers do. If there is a need to handle that case in some specific way, one needs to explicitly check for NaN's before calling MAX or MIN, e.g. by using the IEEE_IS_NAN function from the intrinsic module IEEE_ARITHMETIC.
A new command-line option -fdec-include, set also by the -fdec option, has been added to increase compatibility with legacy code. With this option, an INCLUDE directive is also parsed as a statement, which allows the directive to be spread across multiple source lines with line continuations.
A new BUILTIN directive, has been added. The purpose of the directive is to provide an API between the GCC compiler and the GNU C Library which would define vector implementations of math routines.
module m_part
implicitnoneinteger , parameter :: kd =kind(1.0q0)
real(kd), parameter :: pi =4*atan(1.0_kd)
containscomplex(kd) function cpartition(n)
integer, intent(in) :: n
integer, parameter :: kmax =21 real(kd) :: f, s, t, u
complex(kd) :: c
integer :: j, m, k
cpartition = (0.0_kd, 0.0_kd)
do k =1, kmax
f =sqrt(k /2.0_kd) / pi
c = (0.0_kd, 0.0_kd)
do m =1, k
if (igcd(m, k) ==1) then
s =-real(2* n * m, kd) / k + s_hk(m, k)
c = c +exp(cmplx(0.0_kd, pi * s, kind= kd))
end ifend do
cpartition = cpartition + f * c * da(k, n)
print'(i6, 2f40.5)', k, f * c * da(k, n)
end docontains real(kd) function s_hk(h, k)
integer, intent(in) :: h, k
real(kd) :: t, u
integer :: j
s_hk =0.0_kddo j =1, k -1
t =real(m * j, kd) / k
u =real( j, kd) / k
s_hk = s_hk + (u -floor(u) -0.5_kd) * (t -floor(t) -0.5_kd)
end doend function s_hk
end function cpartition
integerpurefunction igcd(ia, ib)
integer, intent(in) :: ia, ib
integer :: m(2)
m = [ia, ib]
do
m = [m(2), mod(m(1), m(2))]
if (m(2) ==0) exitend do
igcd = m(1)
end function igcd
real(kd) purefunction da(k, n) ! d/dx sinh( f * xs ) / xs ; xs = sqrt(x - 1/24)integer, intent(in) :: k, n
real(kd) :: xs, f
xs =sqrt( real(n, kd) -1.0_kd/24.0_kd )
f = pi / k *sqrt(2.0_kd/3.0_kd)
da = ( f *cosh(f * xs) -sinh(f * xs) / xs ) / (2* xs * xs)
end function da
end module m_part
program Pn
use m_part
implicitnoneinteger :: i
complex(kind= kd) :: z
do i =721, 721
z = cpartition(i)
print*print'(a, i3, a, 2f40.5)', 'p(', i, ')', z
end doend program Pn