-
Notifications
You must be signed in to change notification settings - Fork 0
/
pois.f90
7361 lines (5975 loc) · 180 KB
/
pois.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
MODULE POIS
! CODE CONVERTED USING TO_F90 BY ALAN MILLER
! DATE: 2006-01-18 TIME: 13:48:46
! POISSON SOLVER ROUTINES
USE PRECISION_PARAMETERS
IMPLICIT REAL(EB) (A-H,O-Z)
IMPLICIT INTEGER (I-N)
PRIVATE
REAL(EB) SCALE
INTEGER :: KAPPA,NMAX,IKPWR
LOGICAL :: TPOSE,NOCOPY,OUTARY
CHARACTER(255), PARAMETER :: poisid='$Id: pois.f90 7968 2011-03-24 20:05:55Z mcgratta $'
CHARACTER(255), PARAMETER :: poisrev='$Revision: 7968 $'
CHARACTER(255), PARAMETER :: poisdate='$Date: 2011-03-24 14:05:55 -0600 (Thu, 24 Mar 2011) $'
PUBLIC H3CZIS,H3CZSS,H2CZSS,H2CYSS,H3CSSS,H2CZIS,H3CSIS,H2CYIS,GET_REV_pois
CONTAINS
SUBROUTINE H3CZIS(XS,XF,L,LBDCND,YS,YF,M,MBDCND,ZS,ZF,N,NBDCND, &
H,ELMBDA,LDIMF,MDIMF,IERROR,SAVE)
! +--------------------------------------------------------------------+
! | |
! | COPYRIGHT (C) 1989 BY |
! | ROLAND A. SWEET |
! | ALL RIGHTS RESERVED |
! | |
! +--------------------------------------------------------------------+
REAL(EB):: XS, XF, YS, YF, ZS, ZF, ELMBDA, DLZSQR
INTEGER:: L, LBDCND, M, MBDCND, N, NBDCND, LDIMF, MDIMF, IERROR, LPEROD
REAL(EB) SAVE(-3:*),H(0:*)
! CHECK FOR INVALID INPUT
IERROR = 0
IF (XS>XF) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 1._EB
END IF
IF (L<3) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 2._EB
END IF
IF (LBDCND<0 .OR. LBDCND>4) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 3._EB
END IF
IF (YS>YF) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 4._EB
END IF
IF (M<3) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 5._EB
END IF
IF (MBDCND<0 .OR. MBDCND>4) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 6._EB
END IF
IF (ZS>ZF) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 7._EB
END IF
IF (N<3) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 8._EB
END IF
IF (NBDCND<0 .OR. NBDCND>4) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 9._EB
END IF
IF (LDIMF<L) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 10._EB
END IF
IF (MDIMF<M) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 11._EB
END IF
IF (IERROR/=0) THEN
RETURN
ELSE
SAVE(1) = 0._EB
END IF
! DEFINE GRID PARAMETERS
DX = (XF-XS)/L
DY = (YF-YS)/M
DZ = (ZF-ZS)/N
DLXSQR = 1._EB/DX**2
DLYSQR = 1._EB/DY**2
DLZSQR = 1._EB/DZ**2
LP = LBDCND + 1
MP = MBDCND + 1
NP = NBDCND + 1
! ALLOCATE SAVE ARRAY
IA = 12
IB = IA + L
IC = IB + L
ID = IC + L
IS = ID + L
! DEFINE THE A,B,C COEFFICIENTS
! IN SAVE ARRAY
DO I = 0,L - 1
HM = .5_EB*(H(I)+H(I+1))
HP = .5_EB*(H(I+1)+H(I+2))
SAVE(IA+I) = DLXSQR/(H(I+1)*HM)
SAVE(IC+I) = DLXSQR/(H(I+1)*HP)
SAVE(IB+I) = - (SAVE(IA+I)+SAVE(IC+I)) + ELMBDA
SAVE(ID+I) = DLYSQR
END DO
SELECT CASE(LP)
CASE(2)
SAVE(IB) = SAVE(IB) - SAVE(IA)
SAVE(IC-1) = SAVE(IC-1) - SAVE(ID-1)
CASE(3)
SAVE(IB) = SAVE(IB) - SAVE(IA)
SAVE(IC-1) = SAVE(IC-1) + SAVE(ID-1)
CASE(4)
SAVE(IB) = SAVE(IB) + SAVE(IA)
SAVE(IC-1) = SAVE(IC-1) + SAVE(ID-1)
CASE(5)
SAVE(IB) = SAVE(IB) + SAVE(IA)
SAVE(IC-1) = SAVE(IC-1) - SAVE(ID-1)
END SELECT
! DETERMINE WHETHER OR NOT BOUNDARY
! CONDITION IS PERIODIC IN X
IF (LBDCND==0) THEN
LPEROD = 0
ELSE
LPEROD = 1
END IF
! INITIALIZE SOLVER ROUTINE S3CFIS.
CALL S3CFIS(LPEROD,L,MBDCND,M,NBDCND,N,DLZSQR,SAVE(IA),SAVE(IB), &
SAVE(IC),SAVE(ID),LDIMF,MDIMF,IR,SAVE(IS))
! TEST ERROR FLAG FROM S3CFIS FOR
! INTERNAL ERROR
IF (IR/=0) THEN
SAVE(1) = 99._EB
IERROR = 1
RETURN
END IF
! SAVE PARAMETERS FOR H3CZSS IN SAVE ARRAY
SAVE(2) = DX
SAVE(3) = L
SAVE(4) = LP
SAVE(5) = DY
SAVE(6) = M
SAVE(7) = MP
SAVE(8) = DZ
SAVE(9) = N
SAVE(10) = NP
SAVE(11) = ELMBDA
RETURN
END SUBROUTINE H3CZIS
SUBROUTINE H3CZSS(BDXS,BDXF,BDYS,BDYF,BDZS,BDZF,LDIMF,MDIMF,F, &
PERTRB,SAVE,W,H)
! +--------------------------------------------------------------------+
! | |
! | COPYRIGHT (C) 1989 BY |
! | ROLAND A. SWEET |
! | ALL RIGHTS RESERVED |
! | |
! +--------------------------------------------------------------------+
USE GLOBAL_CONSTANTS, ONLY: PRES_METHOD
REAL(EB):: BDXS(MDIMF,*), BDXF(MDIMF,*), BDYS(LDIMF,*), BDYF(LDIMF,*), BDZS(LDIMF,*), BDZF(LDIMF,*), &
F(LDIMF,MDIMF,*),SAVE(-3:*),W(*),H(0:*), PERTRB
INTEGER:: LDIMF, MDIMF
! CHECK VALUE OF IERROR (=SAVE(1)).
! IF NON-ZERO, RETURN.
IF (ABS(SAVE(1))>=ZERO_P) RETURN
! GET PARAMETERS FOR H3CZSS FROM SAVE
! ARRAY WHERE THEY WERE STORED IN
! INITIALIZATION SUBROUTINE H3CZIS.
DX = SAVE(2)
L = SAVE(3)
LP = SAVE(4)
DY = SAVE(5)
M = SAVE(6)
MP = SAVE(7)
DZ = SAVE(8)
N = SAVE(9)
NP = SAVE(10)
ELMBDA = SAVE(11)
DLYRCP = 1._EB/DY
TWDYSQ = 2._EB/DY**2
DLZRCP = 1._EB/DZ
TWDZSQ = 2._EB/DZ**2
! ALLOCATE SAVE ARRAY
IA = 12
IB = IA + L
IC = IB + L
ID = IC + L
IS = 12 + 4*L
IF (PRES_METHOD /= 'SCARC') THEN
! ENTER BOUNDARY DATA FOR X-BOUNDARIES
IF (LP==2 .OR. LP==3) THEN
DO K = 1,N
DO J = 1,M
F(1,J,K) = F(1,J,K) - 2._EB*BDXS(J,K)*SAVE(IA)
END DO
END DO
END IF
IF (LP==4 .OR. LP==5) THEN
DO K = 1,N
DO J = 1,M
F(1,J,K) = F(1,J,K) + SAVE(IA)*DX*BDXS(J,K)
END DO
END DO
END IF
IF (LP==2 .OR. LP==5) THEN
DO K = 1,N
DO J = 1,M
F(L,J,K) = F(L,J,K) - 2._EB*BDXF(J,K)*SAVE(ID-1)
END DO
END DO
END IF
IF (LP==3 .OR. LP==4) THEN
DO K = 1,N
DO J = 1,M
F(L,J,K) = F(L,J,K) - SAVE(ID-1)*DX*BDXF(J,K)
END DO
END DO
END IF
! ENTER BOUNDARY DATA FOR Y-BOUNDARIES
IF (MP==2 .OR. MP==3) THEN
DO K = 1,N
DO I = 1,L
F(I,1,K) = F(I,1,K) - BDYS(I,K)*TWDYSQ
END DO
END DO
END IF
IF (MP==4 .OR. MP==5) THEN
DO K = 1,N
DO I = 1,L
F(I,1,K) = F(I,1,K) + BDYS(I,K)*DLYRCP
END DO
END DO
END IF
IF (MP==2 .OR. MP==5) THEN
DO K = 1,N
DO I = 1,L
F(I,M,K) = F(I,M,K) - BDYF(I,K)*TWDYSQ
END DO
END DO
END IF
IF (MP==3 .OR. MP==4) THEN
DO K = 1,N
DO I = 1,L
F(I,M,K) = F(I,M,K) - BDYF(I,K)*DLYRCP
END DO
END DO
END IF
! ENTER BOUNDARY DATA FOR Z-BOUNDARIES
IF (NP==2 .OR. NP==3) THEN
DO J = 1,M
DO I = 1,L
F(I,J,1) = F(I,J,1) - BDZS(I,J)*TWDZSQ
END DO
END DO
END IF
IF (NP==4 .OR. NP==5) THEN
DO J = 1,M
DO I = 1,L
F(I,J,1) = F(I,J,1) + BDZS(I,J)*DLZRCP
END DO
END DO
END IF
IF (NP==2 .OR. NP==5) THEN
DO J = 1,M
DO I = 1,L
F(I,J,N) = F(I,J,N) - BDZF(I,J)*TWDZSQ
END DO
END DO
END IF
IF (NP==3 .OR. NP==4) THEN
DO J = 1,M
DO I = 1,L
F(I,J,N) = F(I,J,N) - BDZF(I,J)*DLZRCP
END DO
END DO
END IF
END IF
PERTRB = 0._EB
PERT = 0._EB
ISING = 0
! FOR SINGULAR PROBLEMS ADJUST DATA TO
! INSURE A SOLUTION WILL EXIST. GO THRU
! THIS CODE TWICE: ISING=1 FOR CALCULATING
! PERTRB; ISING=2 FOR NORMALIZING SOLUTION
! AFTER IT IS COMPUTED.
SELECT CASE(LP)
CASE(1) ; GO TO 630
CASE(2:3) ; GO TO 750
CASE(4) ; GO TO 630
CASE(5) ; GO TO 750
END SELECT
630 CONTINUE
SELECT CASE(MP)
CASE(1) ; GO TO 640
CASE(2:3) ; GO TO 750
CASE(4) ; GO TO 640
CASE(5) ; GO TO 750
END SELECT
640 CONTINUE
SELECT CASE(NP)
CASE(1) ; GO TO 650
CASE(2:3) ; GO TO 750
CASE(4) ; GO TO 650
CASE(5) ; GO TO 750
END SELECT
650 CONTINUE
IF (ABS(ELMBDA)>=ZERO_P) GO TO 750
ISING = 1
660 CONTINUE
PERT = 0._EB
DO I = 1,L
W(I) = 0._EB
END DO
DO K = 1,N
DO J = 1,M
DO I = 1,L
W(I) = W(I) + F(I,J,K)
END DO
END DO
END DO
S1 = 0._EB
S3 = 0._EB
DO I = 1,L
S3 = S3 + H(I)
S1 = S1 + H(I)*W(I)
END DO
S3 = S3*M*N
PERT = S1/S3
! ADJUST F ARRAY BY PERT
DO K = 1,N
DO J = 1,M
DO I = 1,L
F(I,J,K) = F(I,J,K) - PERT
END DO
END DO
END DO
750 CONTINUE
! IF NORMALIZING SOLUTION, RESTORE PERTRB
! AND JUMP TO END
IF (ISING==2) THEN
PERTRB = PRTSAV
GO TO 800
END IF
PRTSAV = PERT
! SOLVE THE EQUATION
CALL S3CFSS(LDIMF,MDIMF,F,SAVE(IS),W)
! IF A SINGULAR PROBLEM,
! RE-NORMALIZE SOLUTION (ISING=2)
IF (ISING==1) THEN
ISING = 2
GO TO 660
END IF
800 CONTINUE
RETURN
END SUBROUTINE H3CZSS
SUBROUTINE S3CFIS(LPEROD,L,MPEROD,M,NPEROD,N,SCAL,A,B,C,D,LDIMF, &
MDIMF,IERROR,SAVE)
! +--------------------------------------------------------------------+
! | |
! | COPYRIGHT (C) 1989 BY |
! | ROLAND A. SWEET |
! | ALL RIGHTS RESERVED |
! | |
! +--------------------------------------------------------------------+
INTEGER:: LPEROD, L, MPEROD, M, NPEROD, N
REAL(EB):: SCAL
REAL(EB):: A(L), B(L), C(L), D(L), SAVE(-3:*)
INTEGER:: LDIMF, MDIMF, IERROR
! CHECK FOR INVALID INPUT
IERROR = 0
IF (LPEROD/=0 .AND. LPEROD/=1) THEN
IERROR = 1
SAVE(1) = 1._EB
END IF
IF (L<3) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 2._EB
END IF
IF (MPEROD<0 .AND. MPEROD>4) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 3._EB
END IF
IF (M<3) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 4._EB
END IF
IF (NPEROD<0 .AND. NPEROD>4) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 5._EB
END IF
IF (N<3) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 6._EB
END IF
IF (LDIMF<L) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 7._EB
END IF
IF (MDIMF<M) THEN
IERROR = IERROR + 1
SAVE(IERROR) = 8._EB
END IF
IF (LPEROD==0) THEN
DO I = 1,L
IF (ABS(A(I)-A(1))>=ZERO_P) GO TO 110
IF (ABS(B(I)-B(1))>=ZERO_P) GO TO 110
IF (ABS(C(I)-A(1))>=ZERO_P) GO TO 110
IF (ABS(D(I)-D(1))>=ZERO_P) GO TO 110
END DO
GO TO 120
110 CONTINUE
IERROR = IERROR + 1
SAVE(IERROR) = 9._EB
END IF
120 CONTINUE
IF (IERROR/=0) THEN
RETURN
ELSE
SAVE(1) = IERROR
END IF
LDIMFC=L
IF (LDIMF>L .AND. MOD(L,2)==0) LDIMFC=L+1
IGRID = 2
CALL FSH00S(IGRID,LPEROD,L,MPEROD,M,NPEROD,N,LDIMFC, SCAL,A,B,C,D,SAVE)
RETURN
END SUBROUTINE S3CFIS
SUBROUTINE S3CFSS(LDIMF,MDIMF,F,SAVE,W)
! +--------------------------------------------------------------------+
! | |
! | COPYRIGHT (C) 1989 BY |
! | ROLAND A. SWEET |
! | ALL RIGHTS RESERVED |
! | |
! +--------------------------------------------------------------------+
INTEGER:: LDIMF, MDIMF
REAL(EB) F(LDIMF,MDIMF,*), SAVE(-3:*), W(*)
! CHECK VALUE OF IERROR (=SAVE(1)).
! IF NON-ZERO, RETURN.
IF (ABS(SAVE(1))>=ZERO_P) RETURN
CALL FSH02S(LDIMF,MDIMF,F,SAVE,W)
RETURN
END SUBROUTINE S3CFSS
SUBROUTINE FSH00S(IGRID,LPEROD,L,MPEROD,M,NPEROD,N,LDIMFC,C2, A,B,C,D,SAVE)
! +--------------------------------------------------------------------+
! | |
! | COPYRIGHT (C) 1989 BY |
! | ROLAND A. SWEET |
! | ALL RIGHTS RESERVED |
! | |
! +--------------------------------------------------------------------+
REAL(EB) a(l),b(l),c(l),d(l),save(-3:*), C2
INTEGER:: IGRID, LPEROD, L, MPEROD, M, NPEROD, N, LDIMFC
! THIS SUBROUTINE INITIALIZES FFT SOLVER
! ALLOCATE SAVE ARRAY
IA = 12
IB = IA + L
IC = IB + L
ICFY = IC + L
IF (IGRID==1) THEN
ICFZ = ICFY + 2*M
IFCTRD = ICFZ + 2*N
ELSE
ICFZ = ICFY + 4*M
IFCTRD = ICFZ + 4*N
END IF
IWSY = IFCTRD + LDIMFC*M*N
IWSZ = IWSY + M + 16
IZRT = IWSZ + N + 16
! COPY COEFFICIENT ARRAYS A,B, AND C INTO
! SAVE ARRAY. A COPY OF B IS MADE BECAUSE
! IN THE NEXT LEVEL ROUTINE, BOUNDARY
! ELEMENTS OF B MAY BE CHANGED.
DO I = 0,L - 1
SAVE(IA+I) = A(I+1)
SAVE(IB+I) = B(I+1)
SAVE(IC+I) = C(I+1)
END DO
LP = LPEROD + 1
MP = MPEROD + 1
NP = NPEROD + 1
! CALL LOWER LEVEL INITIALIZATION ROUTINE
CALL FSH01S(IGRID,L,LP,M,MP,D,N,NP,LDIMFC,C2,SAVE(IA),SAVE(IB), &
SAVE(IC),SAVE(ICFY),SAVE(ICFZ),SAVE(IFCTRD), SAVE(IWSY),SAVE(IWSZ),SAVE(IZRT))
! SAVE PARAMETERS FOR SUBROUTINE SOLVER
SAVE(2) = L
SAVE(3) = LP
SAVE(4) = M
SAVE(5) = MP
SAVE(6) = N
SAVE(7) = NP
SAVE(8) = ICFZ
SAVE(9) = IWSZ
SAVE(10) = IZRT
SAVE(11) = IGRID
RETURN
END SUBROUTINE FSH00S
SUBROUTINE FSH01S(IGRID,L,LP,M,MP,D,N,NP,LDIMFC,C2,A,B,C,CFY,CFZ, &
FCTRD,WSAVEY,WSAVEZ,ZRT)
! +--------------------------------------------------------------------+
! | |
! | COPYRIGHT (C) 1989 BY |
! | ROLAND A. SWEET |
! | ALL RIGHTS RESERVED |
! | |
! +--------------------------------------------------------------------+
REAL(EB) a(l),b(l),c(l),d(l),cfy(4*m),cfz(4*n),fctrd(ldimfc,n,m),wsavey(m+16),wsavez(n+16),zrt(n)
INTEGER:: IGRID, L, LP, M, MP, N, NP, LDIMFC, K, I
REAL(EB):: C2
! INITIALIZATION ROUTINE FOR FFT SOLVERS
EPS = FSH20S()
IF (L>1 .AND. LP==1) THEN
LH = (L+1)/2
LODD = 1
IF (2*LH==L) LODD = 2
C(LH-1) = 0._EB
A(LH) = 0._EB
C(LH) = 2._EB*C(LH)
IF (LODD==1) THEN
B(LH-1) = B(LH-1) - A(LH-1)
B(L) = B(L) + A(L)
END IF
IF (LODD==2) A(L) = C(LH)
END IF
! COMPUTE TRANSFORM ROOTS FOR J-DIRECTION
IF (M==1) THEN
CFY(1) = 0._EB
ELSE
IF (IGRID==1) THEN
MRDEL = ((MP-1)* (MP-3)* (MP-5))/3
DEL = PI/ (2._EB* (M+MRDEL))
ELSE
DEL = PI/ (2*M)
END IF
IF (MP==1) THEN
CFY(1) = 0._EB
CFY(M) = -4._EB
DO J = 2,M - 1,2
CFY(J) = -4._EB*SIN(J*DEL)**2
CFY(J+1) = CFY(J)
END DO
END IF
IF (MP==2) THEN
DO J = 1,M
CFY(J) = -4._EB*SIN(J*DEL)**2
END DO
END IF
IF (MP==3 .OR. MP==5) THEN
DO J = 1,M
CFY(J) = -4._EB*SIN((J-.5_EB)*DEL)**2
END DO
END IF
IF (MP==4) THEN
DO J = 1,M
CFY(J) = -4._EB*SIN((J-1)*DEL)**2
END DO
END IF
END IF
! COMPUTE TRANSFORM ROOTS IN K-DIRECTION
IF (N==1) THEN
ZRT(1) = 0._EB
ELSE
IF (IGRID==1) THEN
NRDEL = ((NP-1)* (NP-3)* (NP-5))/3
DEL = PI/ (2._EB* (N+NRDEL))
ELSE
DEL = PI/ (2*N)
END IF
IF (NP==1) THEN
ZRT(1) = 0._EB
ZRT(N) = -4._EB*C2
DO K = 2,N - 1,2
ZRT(K) = -4._EB*C2*SIN(K*DEL)**2
ZRT(K+1) = ZRT(K)
END DO
END IF
IF (NP==2) THEN
DO K = 1,N
ZRT(K) = -4._EB*C2*SIN(K*DEL)**2
END DO
END IF
IF (NP==3 .OR. NP==5) THEN
DO K = 1,N
ZRT(K) = -4._EB*C2*SIN((K-.5_EB)*DEL)**2
END DO
END IF
IF (NP==4) THEN
DO K = 1,N
ZRT(K) = -4._EB*C2*SIN((K-1)*DEL)**2
END DO
END IF
END IF
IF (L>1) THEN
! FACTOR M*N TRIDIAGONAL SYSTEMS.
! FIRST, DO THE POSSIBLY SINGULAR
! CASE CORRESPONDING TO J = K = 1.
FCTRD(1,1,1) = 1._EB/ (B(1)+D(1)*CFY(1)+ZRT(1))
DO I = 2,L - 1
FCTRD(I,1,1) = 1._EB/ (B(I)+D(I)*CFY(1)+ZRT(1)- A(I)*C(I-1)*FCTRD(I-1,1,1))
END DO
! IF TRIDIAGONAL SYSTEM
! (...,A(I),B(I),C(I),...) IS SINGULAR
! THEN FCTRD(1,1,L) IS 1._EB/0. IF
! DENOMINATOR IS WITHIN ROUND-OFF OF 0,
! SET FCTRD(1,1,L) ARBITRARILY
DEN = B(L) + D(L)*CFY(1) + ZRT(1) - A(L)*C(L-1)*FCTRD(L-1,1,1)
BMAX = ABS(B(1))
DO I = 2,L
BMAX = MAX(BMAX,ABS(B(I)))
END DO
IF (ABS(DEN/BMAX)<=10._EB *EPS) DEN = BMAX
FCTRD(L,1,1) = 1._EB/DEN
! FACTOR CASES J=1, K=2,...,N.
DO K = 2,N
FCTRD(1,K,1) = 1._EB/ (B(1)+D(1)*CFY(1)+ZRT(K))
END DO
DO I = 2,L
DO K = 2,N
FCTRD(I,K,1) = 1._EB/ (B(I)+D(I)*CFY(1)+ZRT(K)- A(I)*C(I-1)*FCTRD(I-1,K,1))
END DO
END DO
! FACTOR CASES K=1, J=2,...,M.
DO J = 2,M
FCTRD(1,1,J) = 1._EB/ (B(1)+D(1)*CFY(J)+ZRT(1))
END DO
DO I = 2,L
DO J = 2,M
FCTRD(I,1,J) = 1._EB/ (B(I)+D(I)*CFY(J)+ZRT(1)- A(I)*C(I-1)*FCTRD(I-1,1,J))
END DO
END DO
! FACTOR REMAINING CASES.
DO K = 2,N
DO J = 2,M
FCTRD(1,K,J) = 1._EB/ (B(1)+D(1)*CFY(J)+ZRT(K))
END DO
END DO
DO I = 2,L
DO K = 2,N
DO J = 2,M
FCTRD(I,K,J) = 1._EB/ (B(I)+D(I)*CFY(J)+ZRT(K)- &
A(I)*C(I-1)*FCTRD(I-1,K,J))
END DO
END DO
END DO
END IF
! INITIALIZE FFT TRANSFORMS AND
! PRE-PROCESSING COEFFICIENTS IN J
IF (M/=1) THEN
SELECT CASE(IGRID)
CASE(1) ; GO TO 440
CASE(2) ; GO TO 450
END SELECT
440 CONTINUE
SELECT CASE(MP)
CASE(1) ; GO TO 460
CASE(2) ; GO TO 470
CASE(3) ; GO TO 480
CASE(4) ; GO TO 500
CASE(5) ; GO TO 510
END SELECT
450 CONTINUE
SELECT CASE(MP)
CASE(1) ; GO TO 460
CASE(2) ; GO TO 480
CASE(3) ; GO TO 490
CASE(4) ; GO TO 510
CASE(5) ; GO TO 520
END SELECT
460 CONTINUE
CALL VSRFTI(M,WSAVEY)
GO TO 530
470 CONTINUE
CALL VSINTI(M,CFY,WSAVEY)
GO TO 530
480 CONTINUE
!EB CALL VSSINI(M,CFY(1),CFY(M+1),WSAVEY)
CALL VSCOSI(M,CFY(1),CFY(M+1),WSAVEY)
GO TO 530
490 CONTINUE
!EB CALL VSSNQI(M,CFY(1),CFY(M+1),CFY(2*M+1),CFY(3*M+1),WSAVEY)
CALL VSCSQI(M,CFY(1),CFY(M+1),CFY(2*M+1),CFY(3*M+1),WSAVEY)
GO TO 530
500 CONTINUE
CALL VCOSTI(M,CFY,WSAVEY)
GO TO 530
510 CONTINUE
CALL VSCOSI(M,CFY(1),CFY(M+1),WSAVEY)
GO TO 530
520 CONTINUE
CALL VSCSQI(M,CFY(1),CFY(M+1),CFY(2*M+1),CFY(3*M+1),WSAVEY)
530 CONTINUE
END IF
! INITIALIZE FFT TRANSFORMS AND
! PRE-PROCESSING COEFFICIENTS IN K
IF (N/=1) THEN
SELECT CASE(IGRID)
CASE(1) ; GO TO 540
CASE(2) ; GO TO 550
END SELECT
540 CONTINUE
SELECT CASE(NP)
CASE(1) ; GO TO 560
CASE(2) ; GO TO 570
CASE(3) ; GO TO 580
CASE(4) ; GO TO 600
CASE(5) ; GO TO 610
END SELECT
550 CONTINUE
SELECT CASE(NP)
CASE(1) ; GO TO 560
CASE(2) ; GO TO 580
CASE(3) ; GO TO 590
CASE(4) ; GO TO 610
CASE(5) ; GO TO 620
END SELECT
560 CONTINUE
CALL VSRFTI(N,WSAVEZ)
GO TO 630
570 CONTINUE
CALL VSINTI(N,CFZ,WSAVEZ)
GO TO 630
580 CONTINUE
!EB CALL VSSINI(N,CFZ(1),CFZ(N+1),WSAVEZ)
CALL VSCOSI(N,CFZ(1),CFZ(N+1),WSAVEZ)
GO TO 630
590 CONTINUE
!EB CALL VSSNQI(N,CFZ(1),CFZ(N+1),CFZ(2*N+1),CFZ(3*N+1),WSAVEZ)
CALL VSCSQI(N,CFZ(1),CFZ(N+1),CFZ(2*N+1),CFZ(3*N+1),WSAVEZ)
GO TO 630
600 CONTINUE
CALL VCOSTI(N,CFZ,WSAVEZ)
GO TO 630
610 CONTINUE
CALL VSCOSI(N,CFZ(1),CFZ(N+1),WSAVEZ)
GO TO 630
620 CONTINUE
CALL VSCSQI(N,CFZ(1),CFZ(N+1),CFZ(2*N+1),CFZ(3*N+1),WSAVEZ)
630 CONTINUE
END IF
RETURN
END SUBROUTINE FSH01S
SUBROUTINE FSH02S(LDIMF,MDIMF,F,SAVE,W)
! +--------------------------------------------------------------------+
! | |
! | COPYRIGHT (C) 1989 BY |
! | ROLAND A. SWEET |
! | ALL RIGHTS RESERVED |
! | |
! +--------------------------------------------------------------------+
INTEGER:: LDIMF, MDIMF
REAL(EB) F(LDIMF,MDIMF,*), W(*), SAVE(-3:*)
! RETRIEVE CONSTANTS FROM SAVE ARRAY
L = SAVE(2)
LP = SAVE(3)
M = SAVE(4)
MP = SAVE(5)
N = SAVE(6)
NP = SAVE(7)
IGRID = SAVE(11)
! ALLOCATION OF SAVE ARRAY
IA = 12
IC = IA + 2*L
ICFY = IC + L
IF (IGRID==1) THEN
ICFZ = ICFY + 2*M
IFCTRD = ICFZ + 2*N
ELSE
ICFZ = ICFY + 4*M
IFCTRD = ICFZ + 4*N
END IF
LDIMFC=L
IF (LDIMF>L .AND. MOD(L,2)==0) LDIMFC=L+1
IWSY = IFCTRD + LDIMFC*M*N
IWSZ = IWSY + M + 16
LDIMFT=L