Index: palm/trunk/SOURCE/singleton.f90
===================================================================
--- palm/trunk/SOURCE/singleton.f90	(revision 484)
+++ palm/trunk/SOURCE/singleton.f90	(revision 1320)
@@ -4,16 +4,10 @@
 ! Current revisions:
 ! -----------------
-! 
+! kind-parameters added to all INTEGER and REAL declaration statements,
+! kinds are defined in new module kinds,
+! revision history before 2012 removed,
 !
 ! Former revisions:
 ! -----------------
-! $Id$
-! RCS Log replace by Id keyword, revision history cleaned up
-!
-! Revision 1.2  2004/04/30 12:52:09  raasch
-! Shape of arrays is explicitly stored in ishape and handled to the
-! fft-routines instead of the shape-function (due to a compiler error on
-! decalpha)
-!
 ! Revision 1.1  2002/05/02 18:56:59  raasch
 ! Initial revision
@@ -158,15 +152,15 @@
 !-----------------------------------------------------------------------------
 
+    USE kinds
+
     IMPLICIT NONE
 
     PRIVATE
-    PUBLIC:: fft, fftn, fftkind
-
-    INTEGER, PARAMETER:: fftkind = KIND(0.0) ! adjust here for other precisions
-
-    REAL(fftkind), PARAMETER:: sin60 = 0.86602540378443865_fftkind
-    REAL(fftkind), PARAMETER:: cos72 = 0.30901699437494742_fftkind
-    REAL(fftkind), PARAMETER:: sin72 = 0.95105651629515357_fftkind
-    REAL(fftkind), PARAMETER:: pi    = 3.14159265358979323_fftkind
+    PUBLIC:: fft, fftn
+
+    REAL(wp), PARAMETER:: sin60 = 0.86602540378443865_wp
+    REAL(wp), PARAMETER:: cos72 = 0.30901699437494742_wp
+    REAL(wp), PARAMETER:: sin72 = 0.95105651629515357_wp
+    REAL(wp), PARAMETER:: pi    = 3.14159265358979323_wp
 
     INTERFACE fft
@@ -187,13 +181,13 @@
 !
 !-- Formal parameters
-    COMPLEX(fftkind), DIMENSION(:), INTENT(IN)           :: array
-    INTEGER,          DIMENSION(:), INTENT(IN),  OPTIONAL:: dim
-    LOGICAL,                        INTENT(IN),  OPTIONAL:: inv
-    INTEGER,                        INTENT(OUT), OPTIONAL:: stat
+    COMPLEX(wp),  DIMENSION(:), INTENT(IN)           :: array
+    INTEGER(iwp), DIMENSION(:), INTENT(IN),  OPTIONAL:: dim
+    INTEGER(iwp),               INTENT(OUT), OPTIONAL:: stat
+    LOGICAL,                    INTENT(IN),  OPTIONAL:: inv
 !
 !-- Function result
-    COMPLEX(fftkind), DIMENSION(SIZE(array, 1)):: ft
-
-    INTEGER ::  ishape(1)
+    COMPLEX(wp), DIMENSION(SIZE(array, 1)):: ft
+
+    INTEGER(iwp)::  ishape(1)
 
 !
@@ -211,13 +205,13 @@
 !
 !-- Formal parameters
-    COMPLEX(fftkind), DIMENSION(:,:), INTENT(IN)           :: array
-    INTEGER,          DIMENSION(:),   INTENT(IN),  OPTIONAL:: dim
-    LOGICAL,                          INTENT(IN),  OPTIONAL:: inv
-    INTEGER,                          INTENT(OUT), OPTIONAL:: stat
+    COMPLEX(wp),  DIMENSION(:,:), INTENT(IN)           :: array
+    INTEGER(iwp), DIMENSION(:),   INTENT(IN),  OPTIONAL:: dim
+    INTEGER(iwp),                 INTENT(OUT), OPTIONAL:: stat
+    LOGICAL,                      INTENT(IN),  OPTIONAL:: inv
 !
 !-- Function result
-    COMPLEX(fftkind), DIMENSION(SIZE(array, 1), SIZE(array, 2)):: ft
-
-    INTEGER ::  ishape(2)
+    COMPLEX(wp), DIMENSION(SIZE(array, 1), SIZE(array, 2)):: ft
+
+    INTEGER(iwp) ::  ishape(2)
 !
 !-- Intrinsics used
@@ -234,14 +228,14 @@
 !
 !-- Formal parameters
-    COMPLEX(fftkind), DIMENSION(:,:,:), INTENT(IN)           :: array
-    INTEGER,          DIMENSION(:),     INTENT(IN),  OPTIONAL:: dim
-    LOGICAL,                            INTENT(IN),  OPTIONAL:: inv
-    INTEGER,                            INTENT(OUT), OPTIONAL:: stat
+    COMPLEX(wp),  DIMENSION(:,:,:), INTENT(IN)           :: array
+    INTEGER(iwp), DIMENSION(:),     INTENT(IN),  OPTIONAL:: dim
+    INTEGER(iwp),                   INTENT(OUT), OPTIONAL:: stat
+    LOGICAL,                        INTENT(IN),  OPTIONAL:: inv
 !
 !-- Function result
-    COMPLEX(fftkind), &
+    COMPLEX(wp), &
          DIMENSION(SIZE(array, 1), SIZE(array, 2), SIZE(array, 3)):: ft
 
-    INTEGER ::  ishape(3)
+    INTEGER(iwp) ::  ishape(3)
 
 !
@@ -259,14 +253,14 @@
 !
 !-- Formal parameters
-    COMPLEX(fftkind), DIMENSION(:,:,:,:), INTENT(IN)           :: array
-    INTEGER,          DIMENSION(:),       INTENT(IN),  OPTIONAL:: dim
-    LOGICAL,                              INTENT(IN),  OPTIONAL:: inv
-    INTEGER,                              INTENT(OUT), OPTIONAL:: stat
+    COMPLEX(wp),  DIMENSION(:,:,:,:), INTENT(IN)           :: array
+    INTEGER(iwp), DIMENSION(:),       INTENT(IN),  OPTIONAL:: dim
+    INTEGER(iwp),                     INTENT(OUT), OPTIONAL:: stat
+    LOGICAL,                          INTENT(IN),  OPTIONAL:: inv
 !
 !-- Function result
-    COMPLEX(fftkind), DIMENSION( &
+    COMPLEX(wp), DIMENSION( &
          SIZE(array, 1), SIZE(array, 2), SIZE(array, 3), SIZE(array, 4)):: ft
 
-    INTEGER ::  ishape(4)
+    INTEGER(iwp) ::  ishape(4)
 !
 !-- Intrinsics used
@@ -283,15 +277,15 @@
 !
 !-- Formal parameters
-    COMPLEX(fftkind), DIMENSION(:,:,:,:,:), INTENT(IN)           :: array
-    INTEGER,          DIMENSION(:),         INTENT(IN),  OPTIONAL:: dim
-    LOGICAL,                                INTENT(IN),  OPTIONAL:: inv
-    INTEGER,                                INTENT(OUT), OPTIONAL:: stat
+    COMPLEX(wp),  DIMENSION(:,:,:,:,:), INTENT(IN)           :: array
+    INTEGER(iwp), DIMENSION(:),         INTENT(IN),  OPTIONAL:: dim
+    INTEGER(iwp),                       INTENT(OUT), OPTIONAL:: stat
+    LOGICAL,                            INTENT(IN),  OPTIONAL:: inv
 !
 !-- Function result
-    COMPLEX(fftkind), DIMENSION( &
+    COMPLEX(wp), DIMENSION( &
          SIZE(array, 1), SIZE(array, 2), SIZE(array, 3), SIZE(array, 4), &
          SIZE(array, 5)):: ft
 
-    INTEGER ::  ishape(5)
+    INTEGER(iwp) ::  ishape(5)
 
 !
@@ -309,15 +303,15 @@
 !
 !-- Formal parameters
-    COMPLEX(fftkind), DIMENSION(:,:,:,:,:,:), INTENT(IN)           :: array
-    INTEGER,          DIMENSION(:),           INTENT(IN),  OPTIONAL:: dim
-    LOGICAL,                                  INTENT(IN),  OPTIONAL:: inv
-    INTEGER,                                  INTENT(OUT), OPTIONAL:: stat
+    COMPLEX(wp),  DIMENSION(:,:,:,:,:,:), INTENT(IN)           :: array
+    INTEGER(iwp), DIMENSION(:),           INTENT(IN),  OPTIONAL:: dim
+    INTEGER(iwp),                         INTENT(OUT), OPTIONAL:: stat
+    LOGICAL,                              INTENT(IN),  OPTIONAL:: inv
 !
 !-- Function result
-    COMPLEX(fftkind), DIMENSION( &
+    COMPLEX(wp), DIMENSION( &
          SIZE(array, 1), SIZE(array, 2), SIZE(array, 3), SIZE(array, 4), &
          SIZE(array, 5), SIZE(array, 6)):: ft
 
-    INTEGER ::  ishape(6)
+    INTEGER(iwp) ::  ishape(6)
 
 !
@@ -335,15 +329,15 @@
 !
 !-- Formal parameters
-    COMPLEX(fftkind), DIMENSION(:,:,:,:,:,:,:), INTENT(IN)           :: array
-    INTEGER,          DIMENSION(:),             INTENT(IN),  OPTIONAL:: dim
-    LOGICAL,                                    INTENT(IN),  OPTIONAL:: inv
-    INTEGER,                                    INTENT(OUT), OPTIONAL:: stat
+    COMPLEX(wp), DIMENSION(:,:,:,:,:,:,:), INTENT(IN)           :: array
+    INTEGER(iwp),          DIMENSION(:),   INTENT(IN),  OPTIONAL:: dim
+    INTEGER(iwp),                          INTENT(OUT), OPTIONAL:: stat
+    LOGICAL,                               INTENT(IN),  OPTIONAL:: inv
 !
 !-- Function result
-    COMPLEX(fftkind), DIMENSION( &
+    COMPLEX(wp), DIMENSION( &
          SIZE(array, 1), SIZE(array, 2), SIZE(array, 3), SIZE(array, 4), &
          SIZE(array, 5), SIZE(array, 6), SIZE(array, 7)):: ft
 
-    INTEGER ::  ishape(7)
+    INTEGER(iwp) ::  ishape(7)
 
 !
@@ -361,17 +355,17 @@
 !
 !-- Formal parameters
-    COMPLEX(fftkind), DIMENSION(*), INTENT(INOUT)        :: array
-    INTEGER,          DIMENSION(:), INTENT(IN)           :: shape
-    INTEGER,          DIMENSION(:), INTENT(IN),  OPTIONAL:: dim
-    LOGICAL,                        INTENT(IN),  OPTIONAL:: inv
-    INTEGER,                        INTENT(OUT), OPTIONAL:: stat
+    COMPLEX(wp),  DIMENSION(*), INTENT(INOUT)        :: array
+    INTEGER(iwp), DIMENSION(:), INTENT(IN)           :: shape
+    INTEGER(iwp), DIMENSION(:), INTENT(IN),  OPTIONAL:: dim
+    INTEGER(iwp),               INTENT(OUT), OPTIONAL:: stat
+    LOGICAL,                    INTENT(IN),  OPTIONAL:: inv
 !
 !-- Local arrays
-    INTEGER, DIMENSION(SIZE(shape)):: d
+    INTEGER(iwp), DIMENSION(SIZE(shape)):: d
 !
 !-- Local scalars
     LOGICAL      :: inverse
-    INTEGER      :: i, ndim, ntotal
-    REAL(fftkind):: scale
+    INTEGER(iwp) :: i, ndim, ntotal
+    REAL(wp):: scale
 !
 !-- Intrinsics used
@@ -394,8 +388,8 @@
 
     ntotal = PRODUCT(shape)
-    scale = SQRT(1.0_fftkind / PRODUCT(shape(d(1:ndim))))
+    scale = SQRT(1.0_wp / PRODUCT(shape(d(1:ndim))))
     DO i = 1, ntotal
        array(i) = CMPLX(REAL(array(i)) * scale, AIMAG(array(i)) * scale, &
-            KIND=fftkind)
+            KIND=wp)
     END DO
 
@@ -414,17 +408,17 @@
 !
 !-- Formal parameters
-    COMPLEX(fftkind), DIMENSION(*), INTENT(INOUT)        :: array
-    INTEGER,                        INTENT(IN)           :: ntotal, npass, nspan
-    LOGICAL,                        INTENT(IN)           :: inv
-    INTEGER,                        INTENT(OUT), OPTIONAL:: stat
+    COMPLEX(wp),  DIMENSION(*), INTENT(INOUT)        :: array
+    INTEGER(iwp),               INTENT(IN)           :: ntotal, npass, nspan
+    INTEGER(iwp),               INTENT(OUT), OPTIONAL:: stat
+    LOGICAL,                    INTENT(IN)           :: inv
 !
 !-- Local arrays
-    INTEGER,          DIMENSION(BIT_SIZE(0))     :: factor
-    COMPLEX(fftkind), DIMENSION(:), ALLOCATABLE  :: ctmp
-    REAL(fftkind),    DIMENSION(:), ALLOCATABLE  :: sine, cosine
-    INTEGER,          DIMENSION(:), ALLOCATABLE  :: perm
+    COMPLEX(wp),  DIMENSION(:), ALLOCATABLE  :: ctmp
+    INTEGER(iwp), DIMENSION(BIT_SIZE(0))     :: factor
+    INTEGER(iwp), DIMENSION(:), ALLOCATABLE  :: perm
+    REAL(wp),     DIMENSION(:), ALLOCATABLE  :: sine, cosine
 !
 !-- Local scalars
-    INTEGER         :: maxfactor, nfactor, nsquare, nperm
+    INTEGER(iwp)         :: maxfactor, nfactor, nsquare, nperm
 !
 !-- Intrinsics used
@@ -476,10 +470,10 @@
 !
 !--   Formal parameters
-      INTEGER,               INTENT(IN) :: npass
-      INTEGER, DIMENSION(*), INTENT(OUT):: factor
-      INTEGER,               INTENT(OUT):: nfactor, nsquare
+      INTEGER(iwp),               INTENT(IN) :: npass
+      INTEGER(iwp), DIMENSION(*), INTENT(OUT):: factor
+      INTEGER(iwp),               INTENT(OUT):: nfactor, nsquare
 !
 !--   Local scalars
-      INTEGER:: j, jj, k
+      INTEGER(iwp):: j, jj, k
 
       nfactor = 0
@@ -541,20 +535,20 @@
 !
 !--   Formal parameters
-      COMPLEX(fftkind), DIMENSION(*), INTENT(IN OUT):: array
-      INTEGER,                        INTENT(IN)    :: ntotal, npass, nspan
-      INTEGER,          DIMENSION(*), INTENT(IN)    :: factor
-      INTEGER,                        INTENT(IN)    :: nfactor
-      COMPLEX(fftkind), DIMENSION(*), INTENT(OUT)   :: ctmp
-      REAL(fftkind),    DIMENSION(*), INTENT(OUT)   :: sine, cosine
-      LOGICAL,                        INTENT(IN)    :: inv
+      COMPLEX(wp),  DIMENSION(*), INTENT(IN OUT):: array
+      COMPLEX(wp),  DIMENSION(*), INTENT(OUT)   :: ctmp
+      INTEGER(iwp),               INTENT(IN)    :: ntotal, npass, nspan
+      INTEGER(iwp), DIMENSION(*), INTENT(IN)    :: factor
+      INTEGER(iwp),               INTENT(IN)    :: nfactor
+      LOGICAL,                    INTENT(IN)    :: inv
+      REAL(wp),     DIMENSION(*), INTENT(OUT)   :: sine, cosine
 !
 !--   Local scalars
-      INTEGER         :: ii, ispan
-      INTEGER         :: j, jc, jf, jj
-      INTEGER         :: k, kk, kspan, k1, k2, k3, k4
-      INTEGER         :: nn, nt
-      REAL(fftkind)   :: s60, c72, s72, pi2, radf
-      REAL(fftkind)   :: c1, s1, c2, s2, c3, s3, cd, sd, ak
-      COMPLEX(fftkind):: cc, cj, ck, cjp, cjm, ckp, ckm
+      INTEGER(iwp):: ii, ispan
+      INTEGER(iwp):: j, jc, jf, jj
+      INTEGER(iwp):: k, kk, kspan, k1, k2, k3, k4
+      INTEGER(iwp):: nn, nt
+      REAL(wp)    :: s60, c72, s72, pi2, radf
+      REAL(wp)    :: c1, s1, c2, s2, c3, s3, cd, sd, ak
+      COMPLEX(wp) :: cc, cj, ck, cjp, cjm, ckp, ckm
 
       c72 = cos72
@@ -574,5 +568,5 @@
       jc = nspan / npass
       radf = pi2 * jc
-      pi2 = pi2 * 2.0_fftkind !-- use 2 PI from here on
+      pi2 = pi2 * 2.0_wp !-- use 2 PI from here on
 
       ii = 0
@@ -581,5 +575,5 @@
          sd = radf / kspan
          cd = SIN(sd)
-         cd = 2.0_fftkind * cd * cd
+         cd = 2.0_wp * cd * cd
          sd = SIN(sd + sd)
          kk = 1
@@ -606,5 +600,5 @@
             IF (kk > kspan) RETURN
             DO
-               c1 = 1.0_fftkind - cd
+               c1 = 1.0_wp - cd
                s1 = sd
                DO
@@ -614,5 +608,5 @@
                         ck = array(kk) - array(k2)
                         array(kk) = array(kk) + array(k2)
-                        array(k2) = ck * CMPLX(c1, s1, KIND=fftkind)
+                        array(k2) = ck * CMPLX(c1, s1, KIND=wp)
                         kk = k2 + kspan
                         IF (kk >= nt) EXIT
@@ -625,5 +619,5 @@
                   ak = c1 - (cd * c1 + sd * s1)
                   s1 = sd * c1 - cd * s1 + s1
-                  c1 = 2.0_fftkind - (ak * ak + s1 * s1)
+                  c1 = 2.0_wp - (ak * ak + s1 * s1)
                   s1 = s1 * c1
                   c1 = c1 * ak
@@ -641,6 +635,6 @@
 
             DO
-               c1 = 1.0_fftkind
-               s1 = 0.0_fftkind
+               c1 = 1.0_wp
+               s1 = 0.0_wp
                DO
                   DO
@@ -655,20 +649,20 @@
                      cjp = ckp - cjp
                      IF (inv) THEN
-                        ckp = ckm + CMPLX(-AIMAG(cjm), REAL(cjm), KIND=fftkind)
-                        ckm = ckm + CMPLX(AIMAG(cjm), -REAL(cjm), KIND=fftkind)
+                        ckp = ckm + CMPLX(-AIMAG(cjm), REAL(cjm), KIND=wp)
+                        ckm = ckm + CMPLX(AIMAG(cjm), -REAL(cjm), KIND=wp)
                      ELSE
-                        ckp = ckm + CMPLX(AIMAG(cjm), -REAL(cjm), KIND=fftkind)
-                        ckm = ckm + CMPLX(-AIMAG(cjm), REAL(cjm), KIND=fftkind)
+                        ckp = ckm + CMPLX(AIMAG(cjm), -REAL(cjm), KIND=wp)
+                        ckm = ckm + CMPLX(-AIMAG(cjm), REAL(cjm), KIND=wp)
                      END IF
 !
 !--                  Avoid useless multiplies
-                     IF (s1 == 0.0_fftkind) THEN
+                     IF (s1 == 0.0_wp) THEN
                         array(k1) = ckp
                         array(k2) = cjp
                         array(k3) = ckm
                      ELSE
-                        array(k1) = ckp * CMPLX(c1, s1, KIND=fftkind)
-                        array(k2) = cjp * CMPLX(c2, s2, KIND=fftkind)
-                        array(k3) = ckm * CMPLX(c3, s3, KIND=fftkind)
+                        array(k1) = ckp * CMPLX(c1, s1, KIND=wp)
+                        array(k2) = cjp * CMPLX(c2, s2, KIND=wp)
+                        array(k3) = ckm * CMPLX(c3, s3, KIND=wp)
                      END IF
                      kk = k3 + kspan
@@ -678,5 +672,5 @@
                   c2 = c1 - (cd * c1 + sd * s1)
                   s1 = sd * c1 - cd * s1 + s1
-                  c1 = 2.0_fftkind - (c2 * c2 + s1 * s1)
+                  c1 = 2.0_wp - (c2 * c2 + s1 * s1)
                   s1 = s1 * c1
                   c1 = c1 * c2
@@ -684,5 +678,5 @@
 !--               Values of c2, c3, s2, s3 that will get used next time
                   c2 = c1 * c1 - s1 * s1
-                  s2 = 2.0_fftkind * c1 * s1
+                  s2 = 2.0_wp * c1 * s1
                   c3 = c2 * c1 - s2 * s1
                   s3 = c2 * s1 + s2 * c1
@@ -712,13 +706,13 @@
                      array(kk) = ck + cj
                      ck = ck - CMPLX( &
-                          0.5_fftkind * REAL (cj), &
-                          0.5_fftkind * AIMAG(cj), &
-                          KIND=fftkind)
+                          0.5_wp * REAL (cj), &
+                          0.5_wp * AIMAG(cj), &
+                          KIND=wp)
                      cj = CMPLX( &
                           (REAL (array(k1)) - REAL (array(k2))) * s60, &
                           (AIMAG(array(k1)) - AIMAG(array(k2))) * s60, &
-                          KIND=fftkind)
-                     array(k1) = ck + CMPLX(-AIMAG(cj), REAL(cj), KIND=fftkind)
-                     array(k2) = ck + CMPLX(AIMAG(cj), -REAL(cj), KIND=fftkind)
+                          KIND=wp)
+                     array(k1) = ck + CMPLX(-AIMAG(cj), REAL(cj), KIND=wp)
+                     array(k2) = ck + CMPLX(AIMAG(cj), -REAL(cj), KIND=wp)
                      kk = k2 + kspan
                      IF (kk >= nn) EXIT
@@ -730,5 +724,5 @@
             CASE (5) !-- transform for factor of 5 (optional code)
                c2 = c72 * c72 - s72 * s72
-               s2 = 2.0_fftkind * c72 * s72
+               s2 = 2.0_wp * c72 * s72
                DO
                   DO
@@ -744,23 +738,23 @@
                      array(kk) = cc + ckp + cjp
                      ck = CMPLX(REAL(ckp) * c72, AIMAG(ckp) * c72, &
-                          KIND=fftkind) + &
+                          KIND=wp) + &
                           CMPLX(REAL(cjp) * c2,  AIMAG(cjp) * c2,  &
-                          KIND=fftkind) + cc
+                          KIND=wp) + cc
                      cj = CMPLX(REAL(ckm) * s72, AIMAG(ckm) * s72, &
-                          KIND=fftkind) + &
+                          KIND=wp) + &
                           CMPLX(REAL(cjm) * s2,  AIMAG(cjm) * s2,  &
-                          KIND=fftkind)
-                     array(k1) = ck + CMPLX(-AIMAG(cj), REAL(cj), KIND=fftkind)
-                     array(k4) = ck + CMPLX(AIMAG(cj), -REAL(cj), KIND=fftkind)
+                          KIND=wp)
+                     array(k1) = ck + CMPLX(-AIMAG(cj), REAL(cj), KIND=wp)
+                     array(k4) = ck + CMPLX(AIMAG(cj), -REAL(cj), KIND=wp)
                      ck = CMPLX(REAL(ckp) * c2,  AIMAG(ckp) * c2,  &
-                          KIND=fftkind) + &
+                          KIND=wp) + &
                           CMPLX(REAL(cjp) * c72, AIMAG(cjp) * c72, &
-                          KIND=fftkind) + cc
+                          KIND=wp) + cc
                      cj = CMPLX(REAL(ckm) * s2,  AIMAG(ckm) * s2,  &
-                          KIND=fftkind) - &
+                          KIND=wp) - &
                           CMPLX(REAL(cjm) * s72, AIMAG(cjm) * s72, &
-                          KIND=fftkind)
-                     array(k2) = ck + CMPLX(-AIMAG(cj), REAL(cj), KIND=fftkind)
-                     array(k3) = ck + CMPLX(AIMAG(cj), -REAL(cj), KIND=fftkind)
+                          KIND=wp)
+                     array(k2) = ck + CMPLX(-AIMAG(cj), REAL(cj), KIND=wp)
+                     array(k3) = ck + CMPLX(AIMAG(cj), -REAL(cj), KIND=wp)
                      kk = k4 + kspan
                      IF (kk >= nn) EXIT
@@ -776,6 +770,6 @@
                   c1 = COS(s1)
                   s1 = SIN(s1)
-                  cosine (jf) = 1.0_fftkind
-                  sine (jf) = 0.0_fftkind
+                  cosine (jf) = 1.0_wp
+                  sine (jf) = 0.0_wp
                   j = 1
                   DO
@@ -816,5 +810,5 @@
                         jj = j
                         ck = cc
-                        cj = (0.0_fftkind, 0.0_fftkind)
+                        cj = (0.0_wp, 0.0_wp)
                         k = 1
                         DO
@@ -822,9 +816,9 @@
                            ck = ck + CMPLX( &
                                 REAL (ctmp(k)) * cosine(jj), &
-                                AIMAG(ctmp(k)) * cosine(jj), KIND=fftkind)
+                                AIMAG(ctmp(k)) * cosine(jj), KIND=wp)
                            k = k + 1
                            cj = cj + CMPLX( &
                                 REAL (ctmp(k)) * sine(jj), &
-                                AIMAG(ctmp(k)) * sine(jj), KIND=fftkind)
+                                AIMAG(ctmp(k)) * sine(jj), KIND=wp)
                            jj = jj + j
                            IF (jj > jf) jj = jj - jf
@@ -833,7 +827,7 @@
                         k = jf - j
                         array(k1) = ck + CMPLX(-AIMAG(cj), REAL(cj), &
-                             KIND=fftkind)
+                             KIND=wp)
                         array(k2) = ck + CMPLX(AIMAG(cj), -REAL(cj), &
-                             KIND=fftkind)
+                             KIND=wp)
                         j = j + 1
                         IF (j >= k) EXIT
@@ -852,5 +846,5 @@
             kk = jc + 1
             DO
-               c2 = 1.0_fftkind - cd
+               c2 = 1.0_wp - cd
                s1 = sd
                DO
@@ -860,5 +854,5 @@
                   DO
                      DO
-                        array(kk) = CMPLX(c2, s2, KIND=fftkind) * array(kk)
+                        array(kk) = CMPLX(c2, s2, KIND=wp) * array(kk)
                         kk = kk + ispan
                         IF (kk > nt) EXIT
@@ -872,5 +866,5 @@
                   c2 = c1 - (cd * c1 + sd * s1)
                   s1 = s1 + sd * c1 - cd * s1
-                  c1 = 2.0_fftkind - (c2 * c2 + s1 * s1)
+                  c1 = 2.0_wp - (c2 * c2 + s1 * s1)
                   s1 = s1 * c1
                   c2 = c2 * c1
@@ -892,19 +886,18 @@
 !
 !--   Formal parameters
-      COMPLEX(fftkind), DIMENSION(*), INTENT(IN OUT):: array
-      INTEGER,                        INTENT(IN)    :: ntotal, npass, nspan
-      INTEGER,          DIMENSION(*), INTENT(IN OUT):: factor
-      INTEGER,                        INTENT(IN)    :: nfactor, nsquare
-      INTEGER,                        INTENT(IN)    :: maxfactor
-      COMPLEX(fftkind), DIMENSION(*), INTENT(OUT)   :: ctmp
-      INTEGER,          DIMENSION(*), INTENT(OUT)   :: perm
+      COMPLEX(wp),  DIMENSION(*), INTENT(IN OUT):: array
+      COMPLEX(wp),  DIMENSION(*), INTENT(OUT)   :: ctmp
+      INTEGER(iwp),               INTENT(IN)    :: ntotal, npass, nspan
+      INTEGER(iwp), DIMENSION(*), INTENT(IN OUT):: factor
+      INTEGER(iwp),               INTENT(IN)    :: nfactor, nsquare
+      INTEGER(iwp),               INTENT(IN)    :: maxfactor
+      INTEGER(iwp), DIMENSION(*), INTENT(OUT)   :: perm
 !
 !--   Local scalars
-      INTEGER         :: ii, ispan
-      INTEGER         :: j, jc, jj
-      INTEGER         :: k, kk, kspan, kt, k1, k2, k3
-      INTEGER         :: nn, nt
-      COMPLEX(fftkind):: ck
-
+      COMPLEX(wp) :: ck
+      INTEGER(iwp):: ii, ispan
+      INTEGER(iwp):: j, jc, jj
+      INTEGER(iwp):: k, kk, kspan, kt, k1, k2, k3
+      INTEGER(iwp):: nn, nt
 !
 !--   Permute the results to normal order---done in two stages
