da_find_fft_factors.inc

References to this file elsewhere.
1 subroutine da_find_fft_factors(n, n_ok, fft_factors)
2 
3    !---------------------------------------------------------------------------
4    ! Purpose: Calculates prime factors of input number.
5    !---------------------------------------------------------------------------
6 
7    implicit none
8 
9    integer, intent(in)        :: n
10    logical, intent(out)       :: n_ok
11    integer, intent(out)       :: fft_factors(:)
12 
13    integer                    :: i, k, l
14    integer                    :: nfax, nu, ifac
15    integer                    :: jfax(num_fft_factors)
16    integer                    :: lfax(7)
17 
18    DATA lfax /6,8,5,4,3,2,1/
19 
20    !---------------------------------------------------------------------------
21    ! [1.0] Find factors of vector size (8,6,5,4,3,2; ONLY ONE 8 ALLOWED):
22    !---------------------------------------------------------------------------
23 
24    n_ok = .false.
25    fft_factors(:) = 0
26 
27    ! LOOK FOR SIXES FIRST, STORE FACTORS in DESCendinG ORDER
28    NU=N
29    ifAC=6
30    K=0
31    L=1
32 
33 20 continue
34 
35    if (MOD(NU,ifAC).NE.0) goto 30
36    
37    ! 6 is a factor:
38    K=K+1
39    JFAX(K)=ifAC
40    if (ifAC.NE.8) goto 25
41    if (K.EQ.1) goto 25
42    JFAX(1)=8
43    JFAX(K)=6
44 
45 25 continue
46    NU=NU/ifAC
47    if (NU.EQ.1) goto 50
48    if (ifAC.NE.8) goto 20
49 
50 30 continue
51    L=L+1
52    ifAC=LFAX(L)
53    if (ifAC .GT. 1) goto 20
54 
55    ! Illegal factors:
56    ! write (unit=message(1),fmt='(a,i4,a)') 'N = ', N, ' contains illegal factors.'
57    ! call da_warning(__FILE__,__LINE__,message(1:1))
58    
59    goto 9
60 
61    ! NOW REVERSE ORDER OF FACTORS
62 50 continue
63    NFAX=K
64    fft_factors(1)=NFAX
65    do I=1,NFAX
66       fft_factors(NFAX+2-I)=JFAX(I)
67    end do
68    
69    n_ok = .true.
70       
71 9  continue
72 
73 end subroutine da_find_fft_factors
74 
75