-
Notifications
You must be signed in to change notification settings - Fork 0
/
PMP2mod_fft5.f90
2096 lines (1772 loc) · 55.4 KB
/
PMP2mod_fft5.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!------------------------------------------------------------------
!
! FFT5 routines
!
MODULE FFT5
Contains
!----------------------------
subroutine rfft1b ( n, inc, r, lenr, wsave, lensav, work, lenwrk, ier )
!*****************************************************************************80
!
!! RFFT1B: real single precision backward fast Fourier transform, 1D.
!
! Discussion:
!
! RFFT1B computes the one-dimensional Fourier transform of a periodic
! sequence within a real array. This is referred to as the backward
! transform or Fourier synthesis, transforming the sequence from
! spectral to physical space. This transform is normalized since a
! call to RFFT1B followed by a call to RFFT1F (or vice-versa) reproduces
! the original array within roundoff error.
!
! License:
!
! Licensed under the GNU General Public License (GPL).
! Copyright (C) 1995-2004, Scientific Computing Division,
! University Corporation for Atmospheric Research
!
! Modified:
!
! 25 March 2005
!
! Author:
!
! Paul Swarztrauber
! Richard Valent
!
! Reference:
!
! Paul Swarztrauber,
! Vectorizing the Fast Fourier Transforms,
! in Parallel Computations,
! edited by G. Rodrigue,
! Academic Press, 1982.
!
! Paul Swarztrauber,
! Fast Fourier Transform Algorithms for Vector Computers,
! Parallel Computing, pages 45-63, 1984.
!
! Parameters:
!
! Input, integer ( kind = 4 ) N, the length of the sequence to be
! transformed. The transform is most efficient when N is a product of
! small primes.
!
! Input, integer ( kind = 4 ) INC, the increment between the locations,
! in array R, of two consecutive elements within the sequence.
!
! Input/output, real ( kind = 4 ) R(LENR), on input, the data to be
! transformed, and on output, the transformed data.
!
! Input, integer ( kind = 4 ) LENR, the dimension of the R array.
! LENR must be at least INC*(N-1) + 1.
!
! Input, real ( kind = 4 ) WSAVE(LENSAV). WSAVE's contents must be
! initialized with a call to RFFT1I before the first call to routine
! RFFT1F or RFFT1B for a given transform length N.
!
! Input, integer ( kind = 4 ) LENSAV, the dimension of the WSAVE array.
! LENSAV must be at least N + INT(LOG(REAL(N))) + 4.
!
! Workspace, real ( kind = 4 ) WORK(LENWRK).
!
! Input, integer ( kind = 4 ) LENWRK, the dimension of the WORK array.
! LENWRK must be at least N.
!
! Output, integer ( kind = 4 ) IER, error flag.
! 0, successful exit;
! 1, input parameter LENR not big enough;
! 2, input parameter LENSAV not big enough;
! 3, input parameter LENWRK not big enough.
!
implicit none
integer ( kind = 4 ) lenr
integer ( kind = 4 ) lensav
integer ( kind = 4 ) lenwrk
integer ( kind = 4 ) ier
integer ( kind = 4 ) inc
integer ( kind = 4 ) n
real ( kind = 8 ) r(lenr)
real ( kind = 8 ) work(lenwrk)
real ( kind = 8 ) wsave(lensav)
ier = 0
if ( lenr < inc * ( n - 1 ) + 1 ) then
ier = 1
call xerfft ( 'rfft1b ', 6 )
return
end if
if ( lensav < n + int ( log ( real ( n, kind = 4 ) ) ) + 4 ) then
ier = 2
call xerfft ( 'rfft1b ', 8 )
return
end if
if ( lenwrk < n ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'RFFT1B - Fatal error!'
write ( *, '(a)' ) ' LENWRK < N:'
write ( *, '(a,i6)' ) ' LENWRK = ', lenwrk
write ( *, '(a,i6)' ) ' N = ', n
ier = 3
call xerfft ( 'rfft1b ', 10 )
return
end if
if ( n == 1 ) then
return
end if
call rfftb1 ( n, inc, r, work, wsave, wsave(n+1) )
return
end subroutine rfft1b
subroutine rfft1f ( n, inc, r, lenr, wsave, lensav, work, lenwrk, ier )
!*****************************************************************************80
!
!! RFFT1F: real single precision forward fast Fourier transform, 1D.
!
! Discussion:
!
! RFFT1F computes the one-dimensional Fourier transform of a periodic
! sequence within a real array. This is referred to as the forward
! transform or Fourier analysis, transforming the sequence from physical
! to spectral space. This transform is normalized since a call to
! RFFT1F followed by a call to RFFT1B (or vice-versa) reproduces the
! original array within roundoff error.
!
! License:
!
! Licensed under the GNU General Public License (GPL).
! Copyright (C) 1995-2004, Scientific Computing Division,
! University Corporation for Atmospheric Research
!
! Modified:
!
! 25 March 2005
!
! Author:
!
! Paul Swarztrauber
! Richard Valent
!
! Reference:
!
! Paul Swarztrauber,
! Vectorizing the Fast Fourier Transforms,
! in Parallel Computations,
! edited by G. Rodrigue,
! Academic Press, 1982.
!
! Paul Swarztrauber,
! Fast Fourier Transform Algorithms for Vector Computers,
! Parallel Computing, pages 45-63, 1984.
!
! Parameters:
!
! Input, integer ( kind = 4 ) N, the length of the sequence to be
! transformed. The transform is most efficient when N is a product of
! small primes.
!
! Input, integer ( kind = 4 ) INC, the increment between the locations, in
! array R, of two consecutive elements within the sequence.
!
! Input/output, real ( kind = 8 ) R(LENR), on input, contains the sequence
! to be transformed, and on output, the transformed data.
!
! Input, integer ( kind = 4 ) LENR, the dimension of the R array.
! LENR must be at least INC*(N-1) + 1.
!
! Input, real ( kind = 8 ) WSAVE(LENSAV). WSAVE's contents must be
! initialized with a call to RFFT1I before the first call to routine RFFT1F
! or RFFT1B for a given transform length N.
!
! Input, integer ( kind = 4 ) LENSAV, the dimension of the WSAVE array.
! LENSAV must be at least N + INT(LOG(REAL(N))) + 4.
!
! Workspace, real ( kind = 8 ) WORK(LENWRK).
!
! Input, integer ( kind = 4 ) LENWRK, the dimension of the WORK array.
! LENWRK must be at least N.
!
! Output, integer ( kind = 4 ) IER, error flag.
! 0, successful exit;
! 1, input parameter LENR not big enough:
! 2, input parameter LENSAV not big enough;
! 3, input parameter LENWRK not big enough.
!
implicit none
integer ( kind = 4 ) lenr
integer ( kind = 4 ) lensav
integer ( kind = 4 ) lenwrk
integer ( kind = 4 ) ier
integer ( kind = 4 ) inc
integer ( kind = 4 ) n
real ( kind = 8 ) work(lenwrk)
real ( kind = 8 ) wsave(lensav)
real ( kind = 8 ) r(lenr)
ier = 0
if ( lenr < inc * ( n - 1 ) + 1 ) then
ier = 1
call xerfft ( 'rfft1f ', 6 )
return
end if
if ( lensav < n + int ( log ( real ( n, kind = 4 ) ) ) + 4 ) then
ier = 2
call xerfft ( 'rfft1f ', 8 )
return
end if
if ( lenwrk < n ) then
ier = 3
call xerfft ( 'rfft1f ', 10 )
return
end if
if ( n == 1 ) then
return
end if
call rfftf1 ( n, inc, r, work, wsave, wsave(n+1) )
return
end subroutine rfft1f
subroutine rfft1i ( n, wsave, lensav, ier )
!*****************************************************************************80
!
!! RFFT1I: initialization for RFFT1B and RFFT1F.
!
! Discussion:
!
! RFFT1I initializes array WSAVE for use in its companion routines
! RFFT1B and RFFT1F. The prime factorization of N together with a
! tabulation of the trigonometric functions are computed and stored
! in array WSAVE. Separate WSAVE arrays are required for different
! values of N.
!
! License:
!
! Licensed under the GNU General Public License (GPL).
! Copyright (C) 1995-2004, Scientific Computing Division,
! University Corporation for Atmospheric Research
!
! Modified:
!
! 25 March 2005
!
! Author:
!
! Paul Swarztrauber
! Richard Valent
!
! Reference:
!
! Paul Swarztrauber,
! Vectorizing the Fast Fourier Transforms,
! in Parallel Computations,
! edited by G. Rodrigue,
! Academic Press, 1982.
!
! Paul Swarztrauber,
! Fast Fourier Transform Algorithms for Vector Computers,
! Parallel Computing, pages 45-63, 1984.
!
! Parameters:
!
! Input, integer ( kind = 4 ) N, the length of the sequence to be
! transformed. The transform is most efficient when N is a product of
! small primes.
!
! Output, real ( kind = 8 ) WSAVE(LENSAV), containing the prime factors of
! N and also containing certain trigonometric values which will be used in
! routines RFFT1B or RFFT1F.
!
! Input, integer ( kind = 4 ) LENSAV, the dimension of the WSAVE array.
! LENSAV must be at least N + INT(LOG(REAL(N))) + 4.
!
! Output, integer ( kind = 4 ) IER, error flag.
! 0, successful exit;
! 2, input parameter LENSAV not big enough.
!
implicit none
integer ( kind = 4 ) lensav
integer ( kind = 4 ) ier
integer ( kind = 4 ) n
real ( kind = 8 ) wsave(lensav)
ier = 0
if ( lensav < n + int ( log ( real ( n, kind = 4 ) ) ) + 4 ) then
ier = 2
call xerfft ( 'rfft1i ', 3 )
return
end if
if ( n == 1 ) then
return
end if
call rffti1 ( n, wsave(1), wsave(n+1) )
return
end subroutine rfft1i
subroutine xerfft ( srname, info )
!*****************************************************************************80
!
implicit none
integer ( kind = 4 ) info
character ( len = * ) srname
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'XERFFT - Fatal error!'
if ( 1 <= info ) then
write ( *, '(a,a,a,i3,a)') ' On entry to ', trim ( srname ), &
' parameter number ', info, ' had an illegal value.'
else if ( info == -1 ) then
write( *, '(a,a,a,a)') ' On entry to ', trim ( srname ), &
' parameters LOT, JUMP, N and INC are inconsistent.'
else if ( info == -2 ) then
write( *, '(a,a,a,a)') ' On entry to ', trim ( srname ), &
' parameter L is greater than LDIM.'
else if ( info == -3 ) then
write( *, '(a,a,a,a)') ' On entry to ', trim ( srname ), &
' parameter M is greater than MDIM.'
else if ( info == -5 ) then
write( *, '(a,a,a,a)') ' Within ', trim ( srname ), &
' input error returned by lower level routine.'
else if ( info == -6 ) then
write( *, '(a,a,a,a)') ' On entry to ', trim ( srname ), &
' parameter LDIM is less than 2*(L/2+1).'
end if
stop
end subroutine xerfft
subroutine rfftb1 ( n, in, c, ch, wa, fac )
!*****************************************************************************80
!
implicit none
integer ( kind = 4 ) in
integer ( kind = 4 ) n
real ( kind = 8 ) c(in,*)
real ( kind = 8 ) ch(*)
real ( kind = 8 ) fac(15)
real ( kind = 8 ) half
real ( kind = 8 ) halfm
integer ( kind = 4 ) idl1
integer ( kind = 4 ) ido
integer ( kind = 4 ) ip
integer ( kind = 4 ) iw
integer ( kind = 4 ) ix2
integer ( kind = 4 ) ix3
integer ( kind = 4 ) ix4
integer ( kind = 4 ) j
integer ( kind = 4 ) k1
integer ( kind = 4 ) l1
integer ( kind = 4 ) l2
integer ( kind = 4 ) modn
integer ( kind = 4 ) na
integer ( kind = 4 ) nf
integer ( kind = 4 ) nl
real ( kind = 8 ) wa(n)
nf = int ( fac(2) )
na = 0
do k1 = 1, nf
ip = int ( fac(k1+2) )
na = 1 - na
if ( 5 < ip ) then
if ( k1 /= nf ) then
na = 1 - na
end if
end if
end do
half = 0.5E+00
halfm = -0.5E+00
modn = mod ( n, 2 )
nl = n - 2
if ( modn /= 0 ) then
nl = n - 1
end if
if ( na == 0 ) then
do j = 2, nl, 2
c(1,j) = half * c(1,j)
c(1,j+1) = halfm * c(1,j+1)
end do
else
ch(1) = c(1,1)
ch(n) = c(1,n)
do j = 2, nl, 2
ch(j) = half*c(1,j)
ch(j+1) = halfm*c(1,j+1)
end do
end if
l1 = 1
iw = 1
do k1 = 1, nf
ip = int ( fac(k1+2) )
l2 = ip * l1
ido = n / l2
idl1 = ido * l1
if ( ip == 4 ) then
ix2 = iw + ido
ix3 = ix2 + ido
if ( na == 0 ) then
call r1f4kb ( ido, l1, c, in, ch, 1, wa(iw), wa(ix2), wa(ix3) )
else
call r1f4kb ( ido, l1, ch, 1, c, in, wa(iw), wa(ix2), wa(ix3) )
end if
na = 1 - na
else if ( ip == 2 ) then
if ( na == 0 ) then
call r1f2kb ( ido, l1, c, in, ch, 1, wa(iw) )
else
call r1f2kb ( ido, l1, ch, 1, c, in, wa(iw) )
end if
na = 1 - na
else if ( ip == 3 ) then
ix2 = iw + ido
if ( na == 0 ) then
call r1f3kb ( ido, l1, c, in, ch, 1, wa(iw), wa(ix2) )
else
call r1f3kb ( ido, l1, ch, 1, c, in, wa(iw), wa(ix2) )
end if
na = 1 - na
else if ( ip == 5 ) then
ix2 = iw + ido
ix3 = ix2 + ido
ix4 = ix3 + ido
if ( na == 0 ) then
call r1f5kb ( ido, l1, c, in, ch, 1, wa(iw), wa(ix2), wa(ix3), wa(ix4) )
else
call r1f5kb ( ido, l1, ch, 1, c, in, wa(iw), wa(ix2), wa(ix3), wa(ix4) )
end if
na = 1 - na
else
if ( na == 0 ) then
call r1fgkb ( ido, ip, l1, idl1, c, c, c, in, ch, ch, 1, wa(iw) )
else
call r1fgkb ( ido, ip, l1, idl1, ch, ch, ch, 1, c, c, in, wa(iw) )
end if
if ( ido == 1 ) then
na = 1 - na
end if
end if
l1 = l2
iw = iw + ( ip - 1 ) * ido
end do
return
end subroutine rfftb1
!
!---------------------------------------------
subroutine r1fgkb ( ido, ip, l1, idl1, cc, c1, c2, in1, ch, ch2, in2, wa )
!*****************************************************************************80
!
implicit none
integer ( kind = 4 ) idl1
integer ( kind = 4 ) ido
integer ( kind = 4 ) in1
integer ( kind = 4 ) in2
integer ( kind = 4 ) ip
integer ( kind = 4 ) l1
real ( kind = 8 ) ai1
real ( kind = 8 ) ai2
real ( kind = 8 ) ar1
real ( kind = 8 ) ar1h
real ( kind = 8 ) ar2
real ( kind = 8 ) ar2h
real ( kind = 8 ) arg
real ( kind = 8 ) c1(in1,ido,l1,ip)
real ( kind = 8 ) c2(in1,idl1,ip)
real ( kind = 8 ) cc(in1,ido,ip,l1)
real ( kind = 8 ) ch(in2,ido,l1,ip)
real ( kind = 8 ) ch2(in2,idl1,ip)
real ( kind = 8 ) dc2
real ( kind = 8 ) dcp
real ( kind = 8 ) ds2
real ( kind = 8 ) dsp
integer ( kind = 4 ) i
integer ( kind = 4 ) ic
integer ( kind = 4 ) idij
integer ( kind = 4 ) idp2
integer ( kind = 4 ) ik
integer ( kind = 4 ) ipp2
integer ( kind = 4 ) ipph
integer ( kind = 4 ) is
integer ( kind = 4 ) j
integer ( kind = 4 ) j2
integer ( kind = 4 ) jc
integer ( kind = 4 ) k
integer ( kind = 4 ) l
integer ( kind = 4 ) lc
integer ( kind = 4 ) nbd
real ( kind = 8 ) tpi
real ( kind = 8 ) wa(ido)
tpi = 2.0E+00 * 4.0E+00 * atan ( 1.0E+00 )
arg = tpi / real ( ip, kind = 4 )
dcp = cos ( arg )
dsp = sin ( arg )
idp2 = ido + 2
nbd = ( ido - 1 ) / 2
ipp2 = ip + 2
ipph = ( ip + 1 ) / 2
if ( ido < l1 ) then
do i = 1, ido
do k = 1, l1
ch(1,i,k,1) = cc(1,i,1,k)
end do
end do
else
do k = 1, l1
do i = 1, ido
ch(1,i,k,1) = cc(1,i,1,k)
end do
end do
end if
do j = 2, ipph
jc = ipp2 - j
j2 = j + j
do k = 1, l1
ch(1,1,k,j) = cc(1,ido,j2-2,k)+cc(1,ido,j2-2,k)
ch(1,1,k,jc) = cc(1,1,j2-1,k)+cc(1,1,j2-1,k)
end do
end do
if ( ido == 1 ) then
else if ( nbd < l1 ) then
do j = 2, ipph
jc = ipp2 - j
do i = 3, ido, 2
ic = idp2 - i
do k = 1, l1
ch(1,i-1,k,j) = cc(1,i-1,2*j-1,k)+cc(1,ic-1,2*j-2,k)
ch(1,i-1,k,jc) = cc(1,i-1,2*j-1,k)-cc(1,ic-1,2*j-2,k)
ch(1,i,k,j) = cc(1,i,2*j-1,k)-cc(1,ic,2*j-2,k)
ch(1,i,k,jc) = cc(1,i,2*j-1,k)+cc(1,ic,2*j-2,k)
end do
end do
end do
else
do j = 2, ipph
jc = ipp2 - j
do k = 1, l1
do i = 3, ido, 2
ic = idp2 - i
ch(1,i-1,k,j) = cc(1,i-1,2*j-1,k)+cc(1,ic-1,2*j-2,k)
ch(1,i-1,k,jc) = cc(1,i-1,2*j-1,k)-cc(1,ic-1,2*j-2,k)
ch(1,i,k,j) = cc(1,i,2*j-1,k)-cc(1,ic,2*j-2,k)
ch(1,i,k,jc) = cc(1,i,2*j-1,k)+cc(1,ic,2*j-2,k)
end do
end do
end do
end if
ar1 = 1.0E+00
ai1 = 0.0E+00
do l = 2, ipph
lc = ipp2 - l
ar1h = dcp * ar1 - dsp * ai1
ai1 = dcp * ai1 + dsp * ar1
ar1 = ar1h
do ik = 1, idl1
c2(1,ik,l) = ch2(1,ik,1)+ar1*ch2(1,ik,2)
c2(1,ik,lc) = ai1*ch2(1,ik,ip)
end do
dc2 = ar1
ds2 = ai1
ar2 = ar1
ai2 = ai1
do j = 3, ipph
jc = ipp2 - j
ar2h = dc2*ar2-ds2*ai2
ai2 = dc2*ai2+ds2*ar2
ar2 = ar2h
do ik = 1, idl1
c2(1,ik,l) = c2(1,ik,l)+ar2*ch2(1,ik,j)
c2(1,ik,lc) = c2(1,ik,lc)+ai2*ch2(1,ik,jc)
end do
end do
end do
do j = 2, ipph
do ik = 1, idl1
ch2(1,ik,1) = ch2(1,ik,1)+ch2(1,ik,j)
end do
end do
do j = 2, ipph
jc = ipp2 - j
do k = 1, l1
ch(1,1,k,j) = c1(1,1,k,j)-c1(1,1,k,jc)
ch(1,1,k,jc) = c1(1,1,k,j)+c1(1,1,k,jc)
end do
end do
if ( ido == 1 ) then
else if ( nbd < l1 ) then
do j = 2, ipph
jc = ipp2 - j
do i = 3, ido, 2
do k = 1, l1
ch(1,i-1,k,j) = c1(1,i-1,k,j) - c1(1,i,k,jc)
ch(1,i-1,k,jc) = c1(1,i-1,k,j) + c1(1,i,k,jc)
ch(1,i,k,j) = c1(1,i,k,j) + c1(1,i-1,k,jc)
ch(1,i,k,jc) = c1(1,i,k,j) - c1(1,i-1,k,jc)
end do
end do
end do
else
do j = 2, ipph
jc = ipp2 - j
do k = 1, l1
do i = 3, ido, 2
ch(1,i-1,k,j) = c1(1,i-1,k,j)-c1(1,i,k,jc)
ch(1,i-1,k,jc) = c1(1,i-1,k,j)+c1(1,i,k,jc)
ch(1,i,k,j) = c1(1,i,k,j)+c1(1,i-1,k,jc)
ch(1,i,k,jc) = c1(1,i,k,j)-c1(1,i-1,k,jc)
end do
end do
end do
end if
if ( ido == 1 ) then
return
end if
do ik = 1, idl1
c2(1,ik,1) = ch2(1,ik,1)
end do
do j = 2, ip
do k = 1, l1
c1(1,1,k,j) = ch(1,1,k,j)
end do
end do
if ( l1 < nbd ) then
is = -ido
do j = 2, ip
is = is + ido
do k = 1, l1
idij = is
do i = 3, ido, 2
idij = idij + 2
c1(1,i-1,k,j) = wa(idij-1)*ch(1,i-1,k,j)-wa(idij)* ch(1,i,k,j)
c1(1,i,k,j) = wa(idij-1)*ch(1,i,k,j)+wa(idij)* ch(1,i-1,k,j)
end do
end do
end do
else
is = -ido
do j = 2, ip
is = is + ido
idij = is
do i = 3, ido, 2
idij = idij + 2
do k = 1, l1
c1(1,i-1,k,j) = wa(idij-1) * ch(1,i-1,k,j) - wa(idij) * ch(1,i,k,j)
c1(1,i,k,j) = wa(idij-1) * ch(1,i,k,j) + wa(idij) * ch(1,i-1,k,j)
end do
end do
end do
end if
return
end subroutine r1fgkb
!
!---------------------------------------------
subroutine r1fgkf ( ido, ip, l1, idl1, cc, c1, c2, in1, ch, ch2, in2, wa )
!*****************************************************************************80
!
implicit none
integer ( kind = 4 ) idl1
integer ( kind = 4 ) ido
integer ( kind = 4 ) in1
integer ( kind = 4 ) in2
integer ( kind = 4 ) ip
integer ( kind = 4 ) l1
real ( kind = 8 ) ai1
real ( kind = 8 ) ai2
real ( kind = 8 ) ar1
real ( kind = 8 ) ar1h
real ( kind = 8 ) ar2
real ( kind = 8 ) ar2h
real ( kind = 8 ) arg
real ( kind = 8 ) c1(in1,ido,l1,ip)
real ( kind = 8 ) c2(in1,idl1,ip)
real ( kind = 8 ) cc(in1,ido,ip,l1)
real ( kind = 8 ) ch(in2,ido,l1,ip)
real ( kind = 8 ) ch2(in2,idl1,ip)
real ( kind = 8 ) dc2
real ( kind = 8 ) dcp
real ( kind = 8 ) ds2
real ( kind = 8 ) dsp
integer ( kind = 4 ) i
integer ( kind = 4 ) ic
integer ( kind = 4 ) idij
integer ( kind = 4 ) idp2
integer ( kind = 4 ) ik
integer ( kind = 4 ) ipp2
integer ( kind = 4 ) ipph
integer ( kind = 4 ) is
integer ( kind = 4 ) j
integer ( kind = 4 ) j2
integer ( kind = 4 ) jc
integer ( kind = 4 ) k
integer ( kind = 4 ) l
integer ( kind = 4 ) lc
integer ( kind = 4 ) nbd
real ( kind = 8 ) tpi
real ( kind = 8 ) wa(ido)
tpi = 2.0E+00 * 4.0E+00 * atan ( 1.0E+00 )
arg = tpi / real ( ip, kind = 4 )
dcp = cos ( arg )
dsp = sin ( arg )
ipph = ( ip + 1 ) / 2
ipp2 = ip + 2
idp2 = ido + 2
nbd = ( ido - 1 ) / 2
if ( ido == 1 ) then
do ik = 1, idl1
c2(1,ik,1) = ch2(1,ik,1)
end do
else
do ik = 1, idl1
ch2(1,ik,1) = c2(1,ik,1)
end do
do j = 2, ip
do k = 1, l1
ch(1,1,k,j) = c1(1,1,k,j)
end do
end do
if ( l1 < nbd ) then
is = -ido
do j = 2, ip
is = is + ido
do k = 1, l1
idij = is
do i = 3, ido, 2
idij = idij + 2
ch(1,i-1,k,j) = wa(idij-1)*c1(1,i-1,k,j)+wa(idij) *c1(1,i,k,j)
ch(1,i,k,j) = wa(idij-1)*c1(1,i,k,j)-wa(idij) *c1(1,i-1,k,j)
end do
end do
end do
else
is = -ido
do j = 2, ip
is = is + ido
idij = is
do i = 3, ido, 2
idij = idij + 2
do k = 1, l1
ch(1,i-1,k,j) = wa(idij-1)*c1(1,i-1,k,j)+wa(idij) *c1(1,i,k,j)
ch(1,i,k,j) = wa(idij-1)*c1(1,i,k,j)-wa(idij) *c1(1,i-1,k,j)
end do
end do
end do
end if
if ( nbd < l1 ) then
do j = 2, ipph
jc = ipp2 - j
do i = 3, ido, 2
do k = 1, l1
c1(1,i-1,k,j) = ch(1,i-1,k,j)+ch(1,i-1,k,jc)
c1(1,i-1,k,jc) = ch(1,i,k,j)-ch(1,i,k,jc)
c1(1,i,k,j) = ch(1,i,k,j)+ch(1,i,k,jc)
c1(1,i,k,jc) = ch(1,i-1,k,jc)-ch(1,i-1,k,j)
end do
end do
end do
else
do j = 2, ipph
jc = ipp2 - j
do k = 1, l1
do i = 3, ido, 2
c1(1,i-1,k,j) = ch(1,i-1,k,j)+ch(1,i-1,k,jc)
c1(1,i-1,k,jc) = ch(1,i,k,j)-ch(1,i,k,jc)
c1(1,i,k,j) = ch(1,i,k,j)+ch(1,i,k,jc)
c1(1,i,k,jc) = ch(1,i-1,k,jc)-ch(1,i-1,k,j)
end do
end do
end do
end if
end if
do j = 2, ipph
jc = ipp2 - j
do k = 1, l1
c1(1,1,k,j) = ch(1,1,k,j)+ch(1,1,k,jc)
c1(1,1,k,jc) = ch(1,1,k,jc)-ch(1,1,k,j)
end do
end do
ar1 = 1.0E+00
ai1 = 0.0E+00
do l = 2, ipph
lc = ipp2 - l
ar1h = dcp * ar1 - dsp * ai1
ai1 = dcp * ai1 + dsp * ar1
ar1 = ar1h
do ik = 1, idl1
ch2(1,ik,l) = c2(1,ik,1)+ar1*c2(1,ik,2)
ch2(1,ik,lc) = ai1*c2(1,ik,ip)
end do
dc2 = ar1
ds2 = ai1
ar2 = ar1
ai2 = ai1
do j = 3, ipph
jc = ipp2 - j
ar2h = dc2 * ar2 - ds2 * ai2
ai2 = dc2 * ai2 + ds2 * ar2
ar2 = ar2h
do ik = 1, idl1
ch2(1,ik,l) = ch2(1,ik,l)+ar2*c2(1,ik,j)
ch2(1,ik,lc) = ch2(1,ik,lc)+ai2*c2(1,ik,jc)
end do
end do
end do
do j = 2, ipph
do ik = 1, idl1
ch2(1,ik,1) = ch2(1,ik,1)+c2(1,ik,j)
end do
end do
if ( ido < l1 ) then
do i = 1, ido
do k = 1, l1
cc(1,i,1,k) = ch(1,i,k,1)
end do
end do
else
do k = 1, l1
do i = 1, ido
cc(1,i,1,k) = ch(1,i,k,1)
end do
end do
end if
do j = 2, ipph
jc = ipp2 - j
j2 = j+j
do k = 1, l1
cc(1,ido,j2-2,k) = ch(1,1,k,j)
cc(1,1,j2-1,k) = ch(1,1,k,jc)
end do
end do
if ( ido == 1 ) then
return
end if
if ( nbd < l1 ) then
do j = 2, ipph
jc = ipp2 - j
j2 = j + j
do i = 3, ido, 2
ic = idp2 - i
do k = 1, l1
cc(1,i-1,j2-1,k) = ch(1,i-1,k,j)+ch(1,i-1,k,jc)
cc(1,ic-1,j2-2,k) = ch(1,i-1,k,j)-ch(1,i-1,k,jc)
cc(1,i,j2-1,k) = ch(1,i,k,j)+ch(1,i,k,jc)
cc(1,ic,j2-2,k) = ch(1,i,k,jc)-ch(1,i,k,j)
end do
end do
end do
else