-
Notifications
You must be signed in to change notification settings - Fork 0
/
pfield2lib.f
5313 lines (5313 loc) · 184 KB
/
pfield2lib.f
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
c-----------------------------------------------------------------------
c 2d parallel PIC library for solving field equations
c pfield2lib.f contains procedures to manage guard cells and solve
c fields equations in fourier space:
c PCGUARD2X copy guard cells in x for 2 component vector array,
c quadratic interpolation, and distributed data.
c PBGUARD2X copy guard cells in x for 3 component vector array,
c quadratic interpolation, and distributed data.
c PDGUARD2X copy guard cells in x for scalar array, quadratic
c interpolation, and distributed data.
c PSCGUARD2 initialize field for 3 component vector array, quadratic
c interpolation, and distributed data.
c PSCGUARD22 initialize field for 2 component vector array, quadratic
c interpolation, and distributed data.
c PSGUARD2 initialize field for scalar array, quadratic interpolation,
c and distributed data.
c PACGUARD2X add guard cells in x for 3 component vector array,
c quadratic interpolation, and distributed data.
c PACGUARD22X add guard cells in x for 2 component vector array,
c quadratic interpolation, and distributed data.
c PAGUARD2X add guard cells in x for scalar array, quadratic
c interpolation, and distributed data.
c PZCGUARD2 zeros out guard cells in extended periodic 3 component
c vector field, quadratic interpolation, for distributed data.
c PZCGUARD22 zeros out guard cells in extended periodic 2 component
c vector field, quadratic interpolation, for distributed data
c PZGUARD2 zeros out guard cells in extended periodic scalar field
c quadratic interpolation, for distributed data.
c PCGUARD2XL copy guard cells in x for 2 component vector array, linear
c interpolation, for distributed data.
c PBGUARD2XL copy guard cells in x for 3 component vector array, linear
c interpolation, for distributed data.
c PDGUARD2XL copy guard cells in x for scalar array, linear
c interpolation, for distributed data.
c PSCGUARD2L initialize field for 3 component vector array, linear
c interpolation, for distributed data.
c PSCGUARD22L initialize field for 2 component vector array, linear
c interpolation, for distributed data.
c PSGUARD2L initialize field for scalar array, linear interpolation, for
c distributed data.
c PACGUARD2XL add guard cells in x for 3 component vector array, linear
c interpolation, for distributed data.
c PACGUARD22XL add guard cells in x for 2 component vector array, linear
c interpolation, for distributed data.
c PAGUARD2XL add guard cells in x for scalar array, linear
c interpolation, for distributed data.
c PZCGUARD2L zeros out guard cells in extended periodic 3 component
c vector field, linear interpolation, for distributed data.
c PZCGUARD22L zeros out guard cells in extended periodic 2 component
c vector field, linear interpolation, for distributed data
c PZGUARD2L zeros out guard cells in extended periodic scalar field
c linear interpolation, for distributed data.
c PPOISP2 solve 2d poisson equation for electric force, potential, or
c smoothing, for distributed data.
c PPOISP21 solve 1d poisson equation for electric force, potential, or
c smoothing, for distributed data.
c PPOIS22 solve 2d poisson equation for electric force, for distributed
c data.
c PPOIS23 solve 2-1/2d poisson equation for electric force, for
c distributed data.
c PDIVF2 calculates 2d divergence of n component vector in fourier
c space, for distributed data.
c PGRADF2 calculates 2d gradient of scalar field in fourier space, for
c distributed data.
c PCURLF2 calculates 2d divergence of 3 component vector in fourier
c space, for distributed data.
c PCURLF22 calculates 2d divergence of 2 component vector in fourier
c space, for distributed data.
c PCUPERP2 calculates 2d tranvsere current of 3 component vector in
c fourier space, for distributed data.
c PCUPERP22 calculates 2d tranvsere current of 2 component vector in
c fourier space, for distributed data.
c PBPOISP23 solve 2-1/2d vector poisson equation for magnetic force,
c vector potential, or smoothing, for distributed data.
c PBPOISP22 solve 2d vector poisson equation for magnetic force, vector
c potential, or smoothing, for distributed data.
c IPBPOISP23 solve 2-1/2d vector poisson equation for magnetic field,
c for distributed data.
c PMAXWEL2 solve 2d maxwell equation for electric and magnetic fields,
c for distributed data.
c PEMFIELD2 combines and smooths 2d periodic electric magnetic forces,
c for distributed data.
c PEMFIELDR2 combines and smooths 2d real electric or magnetic forces
c for sine-cosine transforms, for distributed data.
c PAVPOT23 calculate 2-1/2d vector potential from magnetic field, for
c distributed data.
c PAVRPOT32 calculate 2-1/2d radiative part of the vector potential.
c PGTMODES2 extracts selected 2d fourier components from potential
c array, for distributed data.
c PPTMODES2 places selected 2d fourier components into potential array,
c for distributed data.
c PGTVMODES2 extracts selected 2d fourier components from vector
c potential array, for distributed data.
c PPTVMODES2 places selected 2d fourier components into vector potential
c array, for distributed data.
c PPOYNT2 calculate poynting electromagnetic flux.
c PDPOYNT2 calculate electromagnetic flux in 2-1/2d Darwin field.
c PDPOYNT22 calculate electromagnetic flux in 2d Darwin field.
c PSCFGUARD2 initialize 3 component field with scaled vector array,
c quadratic interpolation.
c PSCFGUARD22 initialize 2 component field with scaled vector array,
c quadratic interpolation.
c PSMCGUARD2 initialize field for 4 component tensor array, quadratic
c interpolation.
c PSMCGUARD22 initialize field for 2 component tensor array, quadratic
c interpolation.
c PAMCGUARD2X add guard cells in x for n component tensor array,
c quadratic interpolation, and distributed data.
c PSCFGUARD2L initialize 3 component field with scaled vector array,
c linear interpolation.
c PSCFGUARD22L initialize 2 component field with scaled vector array,
c linear interpolation.
c PSMCGUARD2L initialize field for 4 component tensor array, linear
c interpolation.
c PSMCGUARD22L initialize field for 2 component tensor array, linear
c interpolation.
c PAMCGUARD2XL add guard cells in x for n component tensor array, linear
c interpolation, for distributed data.
c PDCUPERP23 calculate 2-1/d transverse derivative of current density
c from momentum flux.
c PDCUPERP22 calculate 2d transverse derivative of current density from
c momentum flux.
c PADCUPERP23 calculate 2-1/2d transverse derivative of current density
c from momentum flux and acceleration density.
c PADCUPERP22 calculate 2d transverse derivative of current density
c from momentum flux and acceleration density.
c PEPOISP23 solve vector poisson equation for 2-1/2d transverse electric
c field or force.
c PEPOISP22 solve vector poisson equation for 2d transverse electric
c field or force.
c PADDQEI2 adds electron and ion densities, for distributed data.
c PADDQEI2X adds electron and ion densities and calculates maximum and
c minimum plasma frequency, for distributed data.
c PBADDEXT2 adds constant to magnetic field in real space for 2-1/2d
c code, for distributed data.
c PBADDEXT22 adds constant to magnetic field in real space for 2d code,
c for distributed data.
c PIMOMENT2 calculates ion momentum for 2-1/2d code from qi*fxy, for
c distributed data.
c PIMOMENT22 calculates ion momentum for 2d code from qi*fxy, for
c distributed data.
c PADDVRFIELD2 calculates a = b + c for distributed real vector fields.
c written by viktor k. decyk, ucla
c copyright 1995, regents of the university of california
c update: november 15, 2009
c-----------------------------------------------------------------------
subroutine PCGUARD2X(fxy,nyp,nx,nxe,nypmx,nblok)
c replicate extended periodic field
c quadratic interpolation, for distributed data
implicit none
real fxy
integer nyp, nx, nxe, nypmx, nblok
dimension fxy(2,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, k, l, nyp3
do 30 l = 1, nblok
nyp3 = nyp(l) + 3
do 20 k = 1, nyp3
do 10 i = 1, 2
fxy(i,1,k,l) = fxy(i,nx+1,k,l)
fxy(i,nx+2,k,l) = fxy(i,2,k,l)
fxy(i,nx+3,k,l) = fxy(i,3,k,l)
10 continue
20 continue
30 continue
return
end
c-----------------------------------------------------------------------
subroutine PDGUARD2X(q,nyp,nx,nxe,nypmx,nblok)
c replicate extended periodic scalar field
c quadratic interpolation, for distributed data
implicit none
real q
integer nyp, nx, nxe, nypmx, nblok
dimension q(nxe,nypmx,nblok), nyp(nblok)
c local data
integer k, l, nyp3
do 20 l = 1, nblok
nyp3 = nyp(l) + 3
do 10 k = 1, nyp3
q(1,k,l) = q(nx+1,k,l)
q(nx+2,k,l) = q(2,k,l)
q(nx+3,k,l) = q(3,k,l)
10 continue
20 continue
return
end
c-----------------------------------------------------------------------
subroutine PBGUARD2X(bxy,nyp,nx,nxe,nypmx,nblok)
c replicate extended periodic vector field
c quadratic interpolation, for distributed data
implicit none
real bxy
integer nyp, nx, nxe, nypmx, nblok
dimension bxy(3,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, k, l, nyp3
do 30 l = 1, nblok
nyp3 = nyp(l) + 3
do 20 k = 1, nyp3
do 10 i = 1, 3
bxy(i,1,k,l) = bxy(i,nx+1,k,l)
bxy(i,nx+2,k,l) = bxy(i,2,k,l)
bxy(i,nx+3,k,l) = bxy(i,3,k,l)
10 continue
20 continue
30 continue
return
end
c-----------------------------------------------------------------------
subroutine PSCGUARD2(cu,nyp,xj0,yj0,zj0,nx,nxe,nypmx,nblok)
c initialize extended periodic field
c quadratic interpolation, for distributed data
implicit none
real cu, xj0, yj0, zj0
integer nyp, nx, nxe, nypmx, nblok
dimension cu(3,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, j, k, l, nyp3, nx3
c initialize extended field, with zero in the edges
nx3 = nx + 3
do 60 l = 1, nblok
nyp3 = nyp(l) + 3
do 30 k = 1, nyp(l)
do 10 j = 1, nx
cu(1,j+1,k+1,l) = xj0
cu(2,j+1,k+1,l) = yj0
cu(3,j+1,k+1,l) = zj0
10 continue
do 20 i = 1, 3
cu(i,1,k+1,l) = 0.
cu(i,nx+2,k+1,l) = 0.
cu(i,nx+3,k+1,l) = 0.
20 continue
30 continue
do 50 j = 1, nx3
do 40 i = 1, 3
cu(i,j,1,l) = 0.
cu(i,j,nyp3-1,l) = 0.
cu(i,j,nyp3,l) = 0.
40 continue
50 continue
60 continue
return
end
c-----------------------------------------------------------------------
subroutine PSCGUARD22(cu,nyp,xj0,yj0,nx,nxe,nypmx,nblok)
c initialize extended periodic field
c quadratic interpolation, for distributed data
implicit none
real cu, xj0, yj0
integer nyp, nx, nxe, nypmx, nblok
dimension cu(2,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, j, k, l, nyp3, nx3
c initialize extended field, with zero in the edges
nx3 = nx + 3
do 60 l = 1, nblok
nyp3 = nyp(l) + 3
do 30 k = 1, nyp(l)
do 10 j = 1, nx
cu(1,j+1,k+1,l) = xj0
cu(2,j+1,k+1,l) = yj0
10 continue
do 20 i = 1, 2
cu(i,1,k+1,l) = 0.
cu(i,nx+2,k+1,l) = 0.
cu(i,nx+3,k+1,l) = 0.
20 continue
30 continue
do 50 j = 1, nx3
do 40 i = 1, 2
cu(i,j,1,l) = 0.
cu(i,j,nyp3-1,l) = 0.
cu(i,j,nyp3,l) = 0.
40 continue
50 continue
60 continue
return
end
c-----------------------------------------------------------------------
subroutine PSGUARD2(q,nyp,qi0,nx,nxe,nypmx,nblok)
c initialize extended periodic scalar field
c quadratic interpolation, for distributed data
implicit none
real q, qi0
integer nyp, nx, nxe, nypmx, nblok
dimension q(nxe,nypmx,nblok), nyp(nblok)
c local data
integer j, k, l, nyp3, nx3
c initialize extended field, with zero in the edges
nx3 = nx + 3
do 40 l = 1, nblok
nyp3 = nyp(l) + 3
do 20 k = 1, nyp(l)
do 10 j = 1, nx
q(j+1,k+1,l) = qi0
10 continue
q(1,k+1,l) = 0.
q(nx+2,k+1,l) = 0.
q(nx+3,k+1,l) = 0.
20 continue
do 30 j = 1, nx3
q(j,1,l) = 0.
q(j,nyp3-1,l) = 0.
q(j,nyp3,l) = 0.
30 continue
40 continue
return
end
c-----------------------------------------------------------------------
subroutine PACGUARD2X(cu,nyp,nx,nxe,nypmx,nblok)
c accumulate extended periodic vector field
c quadratic interpolation, for distributed data
implicit none
real cu
integer nyp, nx, nxe, nypmx, nblok
dimension cu(3,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, k, l, nyp3
c accumulate edges of extended field
do 30 l = 1, nblok
nyp3 = nyp(l) + 3
do 20 k = 1, nyp3
do 10 i = 1, 3
cu(i,2,k,l) = cu(i,2,k,l) + cu(i,nx+2,k,l)
cu(i,3,k,l) = cu(i,3,k,l) + cu(i,nx+3,k,l)
cu(i,nx+1,k,l) = cu(i,nx+1,k,l) + cu(i,1,k,l)
cu(i,1,k,l) = 0.
cu(i,nx+2,k,l) = 0.
cu(i,nx+3,k,l) = 0.
10 continue
20 continue
30 continue
return
end
c-----------------------------------------------------------------------
subroutine PACGUARD22X(cu,nyp,nx,nxe,nypmx,nblok)
c accumulate extended periodic vector field
c quadratic interpolation, for distributed data
implicit none
real cu
integer nyp, nx, nxe, nypmx, nblok
dimension cu(2,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, k, l, nyp3
c accumulate edges of extended field
do 30 l = 1, nblok
nyp3 = nyp(l) + 3
do 20 k = 1, nyp3
do 10 i = 1, 2
cu(i,2,k,l) = cu(i,2,k,l) + cu(i,nx+2,k,l)
cu(i,3,k,l) = cu(i,3,k,l) + cu(i,nx+3,k,l)
cu(i,nx+1,k,l) = cu(i,nx+1,k,l) + cu(i,1,k,l)
cu(i,1,k,l) = 0.
cu(i,nx+2,k,l) = 0.
cu(i,nx+3,k,l) = 0.
10 continue
20 continue
30 continue
return
end
c-----------------------------------------------------------------------
subroutine PAGUARD2X(q,nyp,nx,nxe,nypmx,nblok)
c accumulate extended periodic scalar field
c quadratic interpolation, for distributed data
implicit none
real q
integer nyp, nx, nxe, nypmx, nblok
dimension q(nxe,nypmx,nblok), nyp(nblok)
c local data
integer k, l, nyp3
c accumulate edges of extended field
do 20 l = 1, nblok
nyp3 = nyp(l) + 3
do 10 k = 1, nyp3
q(2,k,l) = q(2,k,l) + q(nx+2,k,l)
q(3,k,l) = q(3,k,l) + q(nx+3,k,l)
q(nx+1,k,l) = q(nx+1,k,l) + q(1,k,l)
q(1,k,l) = 0.
q(nx+2,k,l) = 0.
q(nx+3,k,l) = 0.
10 continue
20 continue
return
end
c-----------------------------------------------------------------------
subroutine PZCGUARD2(cu,nyp,nx,nxe,nypmx,nblok)
c zero out guard cells in extended periodic vector field
c quadratic interpolation, for distributed data
implicit none
real cu
integer nyp, nx, nxe, nypmx, nblok
dimension cu(3,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, j, k, l, nx3
nx3 = nx + 3
do 50 l = 1, nblok
c zero out guard cells in x
do 20 k = 1, nyp(l)
do 10 i = 1, 3
cu(i,1,k+1,l) = 0.
cu(i,nx+2,k+1,l) = 0.
cu(i,nx+3,k+1,l) = 0.
10 continue
20 continue
c zero out guard cells in y
do 40 j = 1, nx3
do 30 i = 1, 3
cu(i,j,1,l) = 0.
cu(i,j,nyp(l)+2,l) = 0.
cu(i,j,nyp(l)+3,l) = 0.
30 continue
40 continue
50 continue
return
end
c-----------------------------------------------------------------------
subroutine PZCGUARD22(cu,nyp,nx,nxe,nypmx,nblok)
c zero out guard cells in extended periodic vector field
c quadratic interpolation, for distributed data
implicit none
real cu
integer nyp, nx, nxe, nypmx, nblok
dimension cu(2,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, j, k, l, nx3
nx3 = nx + 3
do 50 l = 1, nblok
c zero out guard cells in x
do 20 k = 1, nyp(l)
do 10 i = 1, 2
cu(i,1,k+1,l) = 0.
cu(i,nx+2,k+1,l) = 0.
cu(i,nx+3,k+1,l) = 0.
10 continue
20 continue
c zero out guard cells in y
do 40 j = 1, nx3
do 30 i = 1, 2
cu(i,j,1,l) = 0.
cu(i,j,nyp(l)+2,l) = 0.
cu(i,j,nyp(l)+3,l) = 0.
30 continue
40 continue
50 continue
return
end
c-----------------------------------------------------------------------
subroutine PZGUARD2(q,nyp,nx,nxe,nypmx,nblok)
c zero out guard cells in extended periodic scalar field
c quadratic interpolation, for distributed data
implicit none
real q
integer nyp, nx, nxe, nypmx, nblok
dimension q(nxe,nypmx,nblok), nyp(nblok)
c local data
integer j, k, l, nx3
nx3 = nx + 3
do 30 l = 1, nblok
c zero out guard cells in x
do 10 k = 1, nyp(l)
q(1,k+1,l) = 0.
q(nx+2,k+1,l) = 0.
q(nx+3,k+1,l) = 0.
10 continue
c zero out guard cells in y
do 20 j = 1, nx3
q(j,1,l) = 0.
q(j,nyp(l)+2,l) = 0.
q(j,nyp(l)+3,l) = 0.
20 continue
30 continue
return
end
c-----------------------------------------------------------------------
subroutine PCGUARD2XL(fxy,nyp,nx,nxe,nypmx,nblok)
c replicate extended periodic field
c linear interpolation, for distributed data
implicit none
real fxy
integer nyp, nx, nxe, nypmx, nblok
dimension fxy(2,nxe,nypmx,nblok), nyp(nblok)
c local data
integer k, l, nyp1
do 20 l = 1, nblok
nyp1 = nyp(l) + 1
do 10 k = 1, nyp1
fxy(1,nx+1,k,l) = fxy(1,1,k,l)
fxy(2,nx+1,k,l) = fxy(2,1,k,l)
10 continue
20 continue
return
end
c-----------------------------------------------------------------------
subroutine PDGUARD2XL(q,nyp,nx,nxe,nypmx,nblok)
c replicate extended periodic scalar field
c linear interpolation, for distributed data
implicit none
real q
integer nyp, nx, nxe, nypmx, nblok
dimension q(nxe,nypmx,nblok), nyp(nblok)
c local data
integer k, l, nyp1
do 20 l = 1, nblok
nyp1 = nyp(l) + 1
do 10 k = 1, nyp1
q(nx+1,k,l) = q(1,k,l)
10 continue
20 continue
return
end
c-----------------------------------------------------------------------
subroutine PBGUARD2XL(bxy,nyp,nx,nxe,nypmx,nblok)
c replicate extended periodic vector field
c linear interpolation, for distributed data
implicit none
real bxy
integer nyp, nx, nxe, nypmx, nblok
dimension bxy(3,nxe,nypmx,nblok), nyp(nblok)
c local data
integer k, l, nyp1
do 20 l = 1, nblok
nyp1 = nyp(l) + 1
do 10 k = 1, nyp1
bxy(1,nx+1,k,l) = bxy(1,1,k,l)
bxy(2,nx+1,k,l) = bxy(2,1,k,l)
bxy(3,nx+1,k,l) = bxy(3,1,k,l)
10 continue
20 continue
return
end
c-----------------------------------------------------------------------
subroutine PSCGUARD2L(cu,nyp,xj0,yj0,zj0,nx,nxe,nypmx,nblok)
c initialize extended periodic field
c linear interpolation, for distributed data
implicit none
real cu, xj0, yj0, zj0
integer nyp, nx, nxe, nypmx, nblok
dimension cu(3,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, j, k, l, nyp1, nx1
c initialize extended field, with zero in the edges
nx1 = nx + 1
do 60 l = 1, nblok
nyp1 = nyp(l) + 1
do 30 k = 1, nyp(l)
do 10 j = 1, nx
cu(1,j,k,l) = xj0
cu(2,j,k,l) = yj0
cu(3,j,k,l) = zj0
10 continue
do 20 i = 1, 3
cu(i,nx+1,k,l) = 0.
20 continue
30 continue
do 50 j = 1, nx1
do 40 i = 1, 3
cu(i,j,nyp1,l) = 0.
40 continue
50 continue
60 continue
return
end
c-----------------------------------------------------------------------
subroutine PSCGUARD22L(cu,nyp,xj0,yj0,nx,nxe,nypmx,nblok)
c initialize extended periodic field
c linear interpolation, for distributed data
implicit none
real cu, xj0, yj0
integer nyp, nx, nxe, nypmx, nblok
dimension cu(2,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, j, k, l, nyp1, nx1
c initialize extended field, with zero in the edges
nx1 = nx + 1
do 60 l = 1, nblok
nyp1 = nyp(l) + 1
do 30 k = 1, nyp(l)
do 10 j = 1, nx
cu(1,j,k,l) = xj0
cu(2,j,k,l) = yj0
10 continue
do 20 i = 1, 2
cu(i,nx+1,k,l) = 0.
20 continue
30 continue
do 50 j = 1, nx1
do 40 i = 1, 2
cu(i,j,nyp1,l) = 0.
40 continue
50 continue
60 continue
return
end
c-----------------------------------------------------------------------
subroutine PSGUARD2L(q,nyp,qi0,nx,nxe,nypmx,nblok)
c initialize extended periodic scalar field
c linear interpolation, for distributed data
implicit none
real q, qi0
integer nyp, nx, nxe, nypmx, nblok
dimension q(nxe,nypmx,nblok), nyp(nblok)
c local data
integer j, k, l, nyp1, nx1
c initialize extended field, with zero in the edges
nx1 = nx + 1
do 40 l = 1, nblok
nyp1 = nyp(l) + 1
do 20 k = 1, nyp(l)
do 10 j = 1, nx
q(j,k,l) = qi0
10 continue
q(nx+1,k,l) = 0.
20 continue
do 30 j = 1, nx1
q(j,nyp1,l) = 0.
30 continue
40 continue
return
end
c-----------------------------------------------------------------------
subroutine PACGUARD2XL(cu,nyp,nx,nxe,nypmx,nblok)
c accumulate extended periodic vector field
c linear interpolation, for distributed data
implicit none
real cu
integer nyp, nx, nxe, nypmx, nblok
dimension cu(3,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, k, l, nyp1
c accumulate edges of extended field
do 30 l = 1, nblok
nyp1 = nyp(l) + 1
do 20 k = 1, nyp1
do 10 i = 1, 3
cu(i,1,k,l) = cu(i,1,k,l) + cu(i,nx+1,k,l)
cu(i,nx+1,k,l) = 0.
10 continue
20 continue
30 continue
return
end
c-----------------------------------------------------------------------
subroutine PACGUARD22XL(cu,nyp,nx,nxe,nypmx,nblok)
c accumulate extended periodic vector field
c linear interpolation, for distributed data
implicit none
real cu
integer nyp, nx, nxe, nypmx, nblok
dimension cu(2,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, k, l, nyp1
c accumulate edges of extended field
do 30 l = 1, nblok
nyp1 = nyp(l) + 1
do 20 k = 1, nyp1
do 10 i = 1, 2
cu(i,1,k,l) = cu(i,1,k,l) + cu(i,nx+1,k,l)
cu(i,nx+1,k,l) = 0.
10 continue
20 continue
30 continue
return
end
c-----------------------------------------------------------------------
subroutine PAGUARD2XL(q,nyp,nx,nxe,nypmx,nblok)
c accumulate extended periodic scalar field
c linear interpolation, for distributed data
implicit none
real q
integer nyp, nx, nxe, nypmx, nblok
dimension q(nxe,nypmx,nblok), nyp(nblok)
c local data
integer k, l, nyp1
c accumulate edges of extended field
do 20 l = 1, nblok
nyp1 = nyp(l) + 1
do 10 k = 1, nyp1
q(1,k,l) = q(1,k,l) + q(nx+1,k,l)
q(nx+1,k,l) = 0.
10 continue
20 continue
return
end
c-----------------------------------------------------------------------
subroutine PZCGUARD2L(cu,nyp,nx,nxe,nypmx,nblok)
c zero out guard cells in extended periodic vector field
c linear interpolation, for distributed data
implicit none
real cu
integer nyp, nx, nxe, nypmx, nblok
dimension cu(3,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, j, k, l, nx1
nx1 = nx + 1
c zero out guard cells in x
do 50 l = 1, nblok
c zero out guard cells in x
do 20 k = 1, nyp(l)
do 10 i = 1, 3
cu(i,nx+1,k,l) = 0.
10 continue
20 continue
c zero out guard cells in y
do 40 j = 1, nx1
do 30 i = 1, 3
cu(i,j,nyp(l)+1,l) = 0.
30 continue
40 continue
50 continue
return
end
c-----------------------------------------------------------------------
subroutine PZCGUARD22L(cu,nyp,nx,nxe,nypmx,nblok)
c zero out guard cells in extended periodic vector field
c linear interpolation, for distributed data
implicit none
real cu
integer nyp, nx, nxe, nypmx, nblok
dimension cu(2,nxe,nypmx,nblok), nyp(nblok)
c local data
integer i, j, k, l, nx1
nx1 = nx + 1
c zero out guard cells in x
do 50 l = 1, nblok
c zero out guard cells in x
do 20 k = 1, nyp(l)
do 10 i = 1, 2
cu(i,nx+1,k,l) = 0.
10 continue
20 continue
c zero out guard cells in y
do 40 j = 1, nx1
do 30 i = 1, 2
cu(i,j,nyp(l)+1,l) = 0.
30 continue
40 continue
50 continue
return
end
c-----------------------------------------------------------------------
subroutine PZGUARD2L(q,nyp,nx,nxe,nypmx,nblok)
c zero out guard cells in extended periodic scalar field
c linear interpolation, for distributed data
implicit none
real q
integer nyp, nx, nxe, nypmx, nblok
dimension q(nxe,nypmx,nblok), nyp(nblok)
c local data
integer j, k, l, nx1
nx1 = nx + 1
c zero out guard cells in x
do 30 l = 1, nblok
c zero out guard cells in x
do 10 k = 1, nyp(l)
q(nx+1,k,l) = 0.
10 continue
c zero out guard cells in y
do 20 j = 1, nx1
q(j,nyp(l)+1,l) = 0.
20 continue
30 continue
return
end
c-----------------------------------------------------------------------
subroutine PPOISP2(q,fx,fy,isign,ffc,ax,ay,affp,we,nx,ny,kstrt,nyv
1,kxp,jblok,nyhd)
c this subroutine solves 2d poisson's equation in fourier space for
c force/charge (or convolution of electric field over particle shape)
c or for potential, or provides a smoothing function,
c with periodic boundary conditions for distributed data.
c for isign = 0, input: isign,ax,ay,affp,nx,ny,kstrt,nyv,kxp,jblok,nyhd,
c output: ffc
c for isign = -1, input: q,ffc,isign,nx,ny,kstrt,nyv,kxp,jblok,nyhd,
c output: fx,fy,we
c approximate flop count is: 33*nxc*nyc + 15*(nxc + nyc)
c for isign = 1, input: q,ffc,isign,nx,ny,kstrt,nyv,kxp,jblok,nyhd,
c output: fx,we
c approximate flop count is: 21*nxc*nyc + 11*(nxc + nyc)
c for isign = 2, input: q,ffc,isign,nx,ny,kstrt,nyv,kxp,jblok,nyhd,
c output: fy
c approximate flop count is: 4*nxc*nyc + 2*(nxc + nyc)
c where nxc = (nx/2-1)/nvp, nyc = ny/2 - 1, and nvp = number of procs
c if isign < 0, force/charge is calculated using the equations:
c fx(kx,ky) = -sqrt(-1)*kx*g(kx,ky)*q(kx,ky)*s(kx,ky),
c fy(kx,ky) = -sqrt(-1)*ky*g(kx,ky)*q(kx,ky)*s(kx,ky),
c where kx = 2pi*j/nx, ky = 2pi*k/ny, and j,k = fourier mode numbers,
c g(kx,ky) = (affp/(kx**2+ky**2))*s(kx,ky),
c s(kx,ky) = exp(-((kx*ax)**2+(ky*ay)**2)/2), except for
c fx(kx=pi) = fy(kx=pi) = fx(ky=pi) = fy(ky=pi) = 0, and
c fx(kx=0,ky=0) = fy(kx=0,ky=0) = 0.
c if isign = 1, potential is calculated using the equation:
c fx(kx,ky) = g(kx,ky)*q(kx,ky)
c if isign = 2, smoothing is calculated using the equation:
c fy(kx,ky) = q(kx,ky)*s(kx,ky)
c q(k,j,l) = complex charge density for fourier mode (jj-1,k-1)
c fx(k,j,l) = x component of complex force/charge,
c fy(k,j,l) = y component of complex force/charge,
c for fourier mode (jj-1,k-1), where jj = j + kxp*(l - 1)
c jblok = number of data blocks
c kxp = number of data values per block
c kstrt = starting data block number
c if isign = 0, form factor array is prepared
c aimag(ffc(k,j,l)) = finite-size particle shape factor s
c real(ffc(k,j,l)) = potential green's function g
c for fourier mode (jj-1,k-1), where jj = j + kxp*(l - 1)
c ax/ay = half-width of particle in x/y direction
c affp = normalization constant = nx*ny/np, where np=number of particles
c electric field energy is also calculated, using
c we = nx*ny*sum((affp/(kx**2+ky**2))*|q(kx,ky)*s(kx,ky)|**2)
c nx/ny = system length in x/y direction
c nyv = first dimension of field arrays, must be >= ny
c nyhd = first dimension of form factor array, must be >= nyh
double precision wp
complex q, fx, fy, ffc, zero
dimension q(nyv,kxp,jblok)
dimension fx(nyv,kxp,jblok), fy(nyv,kxp,jblok)
dimension ffc(nyhd,kxp,jblok)
nxh = nx/2
nyh = max(1,ny/2)
ny2 = ny + 2
ks = kstrt - 2
dnx = 6.28318530717959/float(nx)
dny = 6.28318530717959/float(ny)
zero = cmplx(0.,0.)
if (isign.ne.0) go to 40
if (kstrt.gt.nxh) return
c prepare form factor array
do 30 l = 1, jblok
joff = kxp*(l + ks) - 1
do 20 j = 1, kxp
dkx = dnx*float(j + joff)
at1 = dkx*dkx
at2 = (dkx*ax)**2
do 10 k = 1, nyh
dky = dny*float(k - 1)
at3 = dky*dky + at1
at4 = exp(-.5*((dky*ay)**2 + at2))
if (at3.eq.0.) then
ffc(k,j,l) = cmplx(affp,1.)
else
ffc(k,j,l) = cmplx(affp*at4/at3,at4)
endif
10 continue
20 continue
30 continue
return
40 if (isign.gt.0) go to 100
c calculate force/charge and sum field energy
wp = 0.0d0
if (kstrt.gt.nxh) go to 90
do 80 l = 1, jblok
c mode numbers 0 < kx < nx/2 and 0 < ky < ny/2
joff = kxp*(l + ks) - 1
do 60 j = 1, kxp
dkx = dnx*float(j + joff)
if ((j+joff).gt.0) then
do 50 k = 2, nyh
k1 = ny2 - k
at1 = real(ffc(k,j,l))*aimag(ffc(k,j,l))
at2 = dkx*at1
at3 = dny*float(k - 1)*at1
fx(k,j,l) = at2*cmplx(aimag(q(k,j,l)),-real(q(k,j,l)))
fx(k1,j,l) = at2*cmplx(aimag(q(k1,j,l)),-real(q(k1,j,l)))
fy(k,j,l) = at3*cmplx(aimag(q(k,j,l)),-real(q(k,j,l)))
fy(k1,j,l) = at3*cmplx(-aimag(q(k1,j,l)),real(q(k1,j,l)))
wp = wp + at1*(q(k,j,l)*conjg(q(k,j,l)) + q(k1,j,l)*conjg(q(k1,
1j,l)))
50 continue
c mode numbers ky = 0, ny/2
k1 = nyh + 1
at1 = real(ffc(1,j,l))*aimag(ffc(1,j,l))
fx(1,j,l) = dkx*at1*cmplx(aimag(q(1,j,l)),-real(q(1,j,l)))
fx(k1,j,l) = zero
fy(1,j,l) = zero
fy(k1,j,l) = zero
wp = wp + at1*(q(1,j,l)*conjg(q(1,j,l)))
endif
60 continue
c mode numbers kx = 0, nx/2
if ((l+ks).eq.0) then
do 70 k = 2, nyh
k1 = ny2 - k
at1 = real(ffc(k,1,l))*aimag(ffc(k,1,l))
fx(k,1,l) = zero
fx(k1,1,l) = zero
fy(k,1,l) = dny*float(k - 1)*at1*cmplx(aimag(q(k,1,l)),-real(q(
1k,1,l)))
fy(k1,1,l) = zero
wp = wp + at1*(q(k,1,l)*conjg(q(k,1,l)))
70 continue
k1 = nyh + 1
fx(1,1,l) = zero
fx(k1,1,l) = zero
fy(1,1,l) = zero
fy(k1,1,l) = zero
endif
80 continue
90 continue
we = float(nx)*float(ny)*wp
return
c calculate potential and sum field energy
100 if (isign.gt.1) go to 160
wp = 0.0d0
if (kstrt.gt.nxh) go to 150
do 140 l = 1, jblok
c mode numbers 0 < kx < nx/2 and 0 < ky < ny/2
joff = kxp*(l + ks) - 1
do 120 j = 1, kxp
if ((j+joff).gt.0) then
do 110 k = 2, nyh
k1 = ny2 - k
at2 = real(ffc(k,j,l))
at1 = at2*aimag(ffc(k,j,l))
fx(k,j,l) = at2*q(k,j,l)
fx(k1,j,l) = at2*q(k1,j,l)
wp = wp + at1*(q(k,j,l)*conjg(q(k,j,l)) + q(k1,j,l)*conjg(q(k1,
1j,l)))
110 continue
c mode numbers ky = 0, ny/2
k1 = nyh + 1
at2 = real(ffc(1,j,l))
at1 = at2*aimag(ffc(1,j,l))
fx(1,j,l) = at2*q(1,j,l)
fx(k1,j,l) = zero
wp = wp + at1*(q(1,j,l)*conjg(q(1,j,l)))
endif
120 continue
c mode numbers kx = 0, nx/2
if ((l+ks).eq.0) then
do 130 k = 2, nyh
k1 = ny2 - k
at2 = real(ffc(k,1,l))
at1 = at2*aimag(ffc(k,1,l))
fx(k,1,l) = at2*q(k,1,l)
fx(k1,1,l) = zero
wp = wp + at1*(q(k,1,l)*conjg(q(k,1,l)))
130 continue
k1 = nyh + 1
fx(1,1,l) = zero
fx(k1,1,l) = zero
endif
140 continue
150 continue
we = float(nx)*float(ny)*wp
return
c calculate smoothing
160 if (kstrt.gt.nxh) go to 210
do 200 l = 1, jblok
c mode numbers 0 < kx < nx/2 and 0 < ky < ny/2
joff = kxp*(l + ks) - 1
do 180 j = 1, kxp
if ((j+joff).gt.0) then
do 170 k = 2, nyh
k1 = ny2 - k
at1 = aimag(ffc(k,j,l))
fy(k,j,l) = at1*q(k,j,l)
fy(k1,j,l) = at1*q(k1,j,l)
170 continue
c mode numbers ky = 0, ny/2
k1 = nyh + 1
at1 = aimag(ffc(1,j,l))
fy(1,j,l) = at1*q(1,j,l)
fy(k1,j,l) = zero
endif
180 continue
c mode numbers kx = 0, nx/2
if ((l+ks).eq.0) then
do 190 k = 2, nyh
k1 = ny2 - k
at1 = aimag(ffc(k,1,l))
fy(k,1,l) = at1*q(k,1,l)
fy(k1,1,l) = zero
190 continue
k1 = nyh + 1
fy(1,1,l) = cmplx(aimag(ffc(1,1,l))*real(q(1,1,l)),0.)
fy(k1,1,l) = zero
endif
200 continue
210 continue
return
end
c-----------------------------------------------------------------------
subroutine PPOISP21(q,fx,isign,ffc,ax,affp,we,nx,kstrt,kxp,jblok)
c this subroutine solves 1d poisson's equation in fourier space for
c force/charge (or convolution of electric field over particle shape)
c or for potential, or provides a smoothing function,
c with periodic boundary conditions for distributed data.
c for isign = 0, input: isign,ax,affp,nx,kstrt,kxp,jblok, output: ffc
c for isign = -1, input: q,ffc,isign,nx,kstrt,kxp,jblok, output: fx,we
c approximate flop count is: 15*nxc
c for isign = 1, input: q,ffc,isign,nx,kstrt,kxp,jblok, output: fx,we
c approximate flop count is: 11*nxc
c for isign = 2, input: q,ffc,isign,nx,kstrt,kxp,jblok, output: fx
c approximate flop count is: 2*nxc
c where nxc = (nx/2-1)/nvp, and nvp = number of procs
c if isign < 0, force/charge is calculated using the equations:
c fx(kx) = -sqrt(-1)*kx*g(kx)*q(kx)*s(kx),
c where kx = 2pi*j/nx, and j = fourier mode number,