-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppush2lib.f
2398 lines (2398 loc) · 86.4 KB
/
ppush2lib.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 pushing particles and depositing charge
c ppush2lib.f contains procedures to process particles:
c PGPOST2 deposits charge density, quadratic interpolation, STANDARD
c optimization, and distributed data.
c PGSPOST2 deposits charge density, quadratic interpolation, LOOKAHEAD
c optimization, and distributed data.
c PGSOST2X deposits charge density, quadratic interpolation, VECTOR
c optimization, and distributed data.
c PGPOST2L deposits charge density, linear interpolation, STANDARD
c optimization, and distributed data.
c PGSPOST2L deposits charge density, linear interpolation, LOOKAHEAD
c optimization, and distributed data.
c PGSOST2XL deposits charge density, linear interpolation, VECTOR
c optimization, and distributed data.
c PGPUSH2 push particles, quadratic interpolation, STANDARD
c optimization, and distributed data.
c PGSPUSH2 push particles, quadratic interpolation, LOOKAHEAD
c optimization, and distributed data.
c PGPUSH2L push particles, linear interpolation, STANDARD optimization,
c and distributed data.
c PGSPUSH2L push particles, linear interpolation, LOOKAHEAD
c optimization, and distributed data.
c PSORTP2Y sort particles by y grid, quadratic interpolation, memory
c conserving algorithm, and distributed data.
c PSORTP2YL sort particles by y grid, linear interpolation, memory
c conserving algorithm, and distributed data.
c PDSORTP2Y sort particles by y grid, quadratic interpolation, high
c performance algorithm, and distributed data.
c PDSORTP2YL sort particles by y grid, linear interpolation, high
c performance algorithm, and distributed data.
c PCOUNT2YL counts particles by y grid, accumulating into npic array,
c with distributed data.
c PRMOVE2 remove particles instead of reflecting at boundary, with
c distributed data.
c PPUSH2ZF update particle co-ordinates for particles with fixed
c velocities, and distributed data.
c PGCJPOST2 deposits time-centered particle current density, quadratic
c interpolation, and distributed data.
c PGCJPOST2L deposits time-centered particle current density, linear
c interpolation, and distributed data.
c written by viktor k. decyk, ucla
c copyright 1995, regents of the university of california
c update: august 22, 2009
c-----------------------------------------------------------------------
subroutine PDOST2(part,q,npp,noff,qm,nx,idimp,npmax,nblok,nxv,nypm
1x)
c for 2d code, this subroutine calculates particle charge density
c using second-order spline interpolation, periodic boundaries
c and distributed data.
c baseline scalar distributed version
c 43 flops/particle, 11 loads, 9 stores
c input: all, output: q
c charge density is approximated by values at the nearest grid points
c q(n,m)=qm*(.75-dx**2)*(.75-dy**2)
c q(n+1,m)=.5*qm*((.5+dx)**2)*(.75-dy**2)
c q(n-1,m)=.5*qm*((.5-dx)**2)*(.75-dy**2)
c q(n,m+1)=.5*qm*(.75-dx**2)*(.5+dy)**2
c q(n+1,m+1)=.25*qm*((.5+dx)**2)*(.5+dy)**2
c q(n-1,m+1)=.25*qm*((.5-dx)**2)*(.5+dy)**2
c q(n,m-1)=.5*qm*(.75-dx**2)*(.5-dy)**2
c q(n+1,m-1)=.25*qm*((.5+dx)**2)*(.5-dy)**2
c q(n-1,m-1)=.25*qm*((.5-dx)**2)*(.5-dy)**2
c where n,m = nearest grid points and dx = x-n, dy = y-m
c part(1,n,l) = position x of particle n in partition l
c part(2,n,l) = position y of particle n in partition l
c q(j,k,l) = charge density at grid point (j,kk),
c where kk = k + noff(l) - 1
c npp(l) = number of particles in partition l
c noff(l) = lowermost global gridpoint in particle partition l.
c qm = charge on particle, in units of e
c idimp = size of phase space = 4
c nx = system length in x direction
c npmax = maximum number of particles in each partition
c nblok = number of particle partitions.
c nxv = first dimension of charge array, must be >= nx
c nypmx = maximum size of particle partition, including guard cells.
dimension part(idimp,npmax,nblok), q(nxv,nypmx,nblok)
dimension npp(nblok), noff(nblok)
qmh = .5*qm
do 20 l = 1, nblok
mnoff = noff(l) - 2
do 10 j = 1, npp(l)
c find interpolation weights
nn = part(1,j,l) + .5
mm = part(2,j,l) + .5
dxp = part(1,j,l) - float(nn)
dyp = part(2,j,l) - float(mm)
nl = nn
if (nl.lt.1) nl = nl + nx
amx = qm*(.75 - dxp*dxp)
mm = mm - mnoff
amy = .75 - dyp*dyp
nn = nn + 1
if (nn.gt.nx) nn = nn - nx
dxl = qmh*(.5 - dxp)**2
np = nn + 1
if (np.gt.nx) np = np - nx
dxp = qmh*(.5 + dxp)**2
ml = mm - 1
dyl = .5*(.5 - dyp)**2
mp = mm + 1
dyp = .5*(.5 + dyp)**2
c deposit charge
q(nl,mm,l) = q(nl,mm,l) + dxl*amy
q(nn,mm,l) = q(nn,mm,l) + amx*amy
q(np,mm,l) = q(np,mm,l) + dxp*amy
q(nl,ml,l) = q(nl,ml,l) + dxl*dyl
q(nn,ml,l) = q(nn,ml,l) + amx*dyl
q(np,ml,l) = q(np,ml,l) + dxp*dyl
q(nl,mp,l) = q(nl,mp,l) + dxl*dyp
q(nn,mp,l) = q(nn,mp,l) + amx*dyp
q(np,mp,l) = q(np,mp,l) + dxp*dyp
10 continue
20 continue
return
end
c-----------------------------------------------------------------------
subroutine PGPOST2(part,q,npp,noff,qm,idimp,npmax,nblok,nxv,nypmx)
c for 2d code, this subroutine calculates particle charge density
c using second-order spline interpolation, periodic boundaries
c and distributed data.
c scalar version using guard cells, for distributed data
c 43 flops/particle, 11 loads, 9 stores
c input: all, output: q
c charge density is approximated by values at the nearest grid points
c q(n,m)=qm*(.75-dx**2)*(.75-dy**2)
c q(n+1,m)=.5*qm*((.5+dx)**2)*(.75-dy**2)
c q(n-1,m)=.5*qm*((.5-dx)**2)*(.75-dy**2)
c q(n,m+1)=.5*qm*(.75-dx**2)*(.5+dy)**2
c q(n+1,m+1)=.25*qm*((.5+dx)**2)*(.5+dy)**2
c q(n-1,m+1)=.25*qm*((.5-dx)**2)*(.5+dy)**2
c q(n,m-1)=.5*qm*(.75-dx**2)*(.5-dy)**2
c q(n+1,m-1)=.25*qm*((.5+dx)**2)*(.5-dy)**2
c q(n-1,m-1)=.25*qm*((.5-dx)**2)*(.5-dy)**2
c where n,m = nearest grid points and dx = x-n, dy = y-m
c part(1,n,l) = position x of particle n in partition l
c part(2,n,l) = position y of particle n in partition l
c q(j+1,k,l) = charge density at grid point (j,kk),
c where kk = k + noff(l) - 1
c npp(l) = number of particles in partition l
c noff(l) = lowermost global gridpoint in particle partition l.
c qm = charge on particle, in units of e
c idimp = size of phase space = 4
c npmax = maximum number of particles in each partition
c nblok = number of particle partitions.
c nxv = first dimension of charge array, must be >= nx+3
c nypmx = maximum size of particle partition, including guard cells.
dimension part(idimp,npmax,nblok), q(nxv,nypmx,nblok)
dimension npp(nblok), noff(nblok)
qmh = .5*qm
do 20 l = 1, nblok
mnoff = noff(l) - 1
do 10 j = 1, npp(l)
c find interpolation weights
nn = part(1,j,l) + .5
mm = part(2,j,l) + .5
dxp = part(1,j,l) - float(nn)
dyp = part(2,j,l) - float(mm)
nl = nn + 1
amx = qm*(.75 - dxp*dxp)
ml = mm - mnoff
amy = .75 - dyp*dyp
nn = nl + 1
dxl = qmh*(.5 - dxp)**2
np = nl + 2
dxp = qmh*(.5 + dxp)**2
mm = ml + 1
dyl = .5*(.5 - dyp)**2
mp = ml + 2
dyp = .5*(.5 + dyp)**2
c deposit charge
q(nl,mm,l) = q(nl,mm,l) + dxl*amy
q(nn,mm,l) = q(nn,mm,l) + amx*amy
q(np,mm,l) = q(np,mm,l) + dxp*amy
q(nl,ml,l) = q(nl,ml,l) + dxl*dyl
q(nn,ml,l) = q(nn,ml,l) + amx*dyl
q(np,ml,l) = q(np,ml,l) + dxp*dyl
q(nl,mp,l) = q(nl,mp,l) + dxl*dyp
q(nn,mp,l) = q(nn,mp,l) + amx*dyp
q(np,mp,l) = q(np,mp,l) + dxp*dyp
10 continue
20 continue
return
end
c-----------------------------------------------------------------------
subroutine PGSPOST2(part,q,npp,noff,qm,idimp,npmax,nblok,nxv,nxyp)
c for 2d code, this subroutine calculates particle charge density
c using second-order spline interpolation, periodic boundaries
c and distributed data.
c scalar version using guard cells, integer conversion precalculation,
c and 1d addressing, for distributed data
c cases 9-10 in v.k.decyk et al, computers in physics 10, 290 (1996).
c 43 flops/particle, 11 loads, 9 stores
c input: all, output: q
c charge density is approximated by values at the nearest grid points
c q(n,m)=qm*(.75-dx**2)*(.75-dy**2)
c q(n+1,m)=.5*qm*((.5+dx)**2)*(.75-dy**2)
c q(n-1,m)=.5*qm*((.5-dx)**2)*(.75-dy**2)
c q(n,m+1)=.5*qm*(.75-dx**2)*(.5+dy)**2
c q(n+1,m+1)=.25*qm*((.5+dx)**2)*(.5+dy)**2
c q(n-1,m+1)=.25*qm*((.5-dx)**2)*(.5+dy)**2
c q(n,m-1)=.5*qm*(.75-dx**2)*(.5-dy)**2
c q(n+1,m-1)=.25*qm*((.5+dx)**2)*(.5-dy)**2
c q(n-1,m-1)=.25*qm*((.5-dx)**2)*(.5-dy)**2
c where n,m = nearest grid points and dx = x-n, dy = y-m
c part(1,n,l) = position x of particle n in partition l
c part(2,n,l) = position y of particle n in partition l
c q(j+1,k,l) = charge density at grid point (j,kk),
c where kk = k + noff(l) - 1
c npp(l) = number of particles in partition l
c noff(l) = lowermost global gridpoint in particle partition l.
c qm = charge on particle, in units of e
c idimp = size of phase space = 4
c npmax = maximum number of particles in each partition
c nblok = number of particle partitions.
c nxv = first virtual dimension of charge array, must be >= nx+3
c nxyp = first actual dimension of charge array, must be >= nxv*nypmx
dimension part(idimp,npmax,nblok), q(nxyp,nblok)
dimension npp(nblok), noff(nblok)
qmh = .5*qm
do 20 l = 1, nblok
if (npp(l).lt.1) go to 20
mnoff = noff(l)
c begin first particle
nnn = part(1,1,l) + .5
mmn = part(2,1,l) + .5
dxn = part(1,1,l) - float(nnn)
dyn = part(2,1,l) - float(mmn)
mmn = mmn - mnoff
do 10 j = 2, npp(l)
c find interpolation weights
nn = nnn + 1
mm = nxv*mmn
nnn = part(1,j,l) + .5
mmn = part(2,j,l) + .5
dxp = dxn
dyp = dyn
dxn = part(1,j,l) - float(nnn)
dyn = part(2,j,l) - float(mmn)
ml = mm + nn
amx = qm*(.75 - dxp*dxp)
amy = .75 - dyp*dyp
mn = ml + nxv
dxl = qmh*(.5 - dxp)**2
dxp = qmh*(.5 + dxp)**2
mp = mn + nxv
dyl = .5*(.5 - dyp)**2
dyp = .5*(.5 + dyp)**2
mmn = mmn - mnoff
c deposit charge
dx = q(mn,l) + dxl*amy
dy = q(mn+1,l) + amx*amy
amy = q(mn+2,l) + dxp*amy
dx1 = q(ml,l) + dxl*dyl
dy1 = q(ml+1,l) + amx*dyl
dyl = q(ml+2,l) + dxp*dyl
dxl = q(mp,l) + dxl*dyp
amx = q(mp+1,l) + amx*dyp
dyp = q(mp+2,l) + dxp*dyp
q(mn,l) = dx
q(mn+1,l) = dy
q(mn+2,l) = amy
q(ml,l) = dx1
q(ml+1,l) = dy1
q(ml+2,l) = dyl
q(mp,l) = dxl
q(mp+1,l) = amx
q(mp+2,l) = dyp
10 continue
c deposit charge for last particle
nn = nnn + 1
mm = nxv*mmn
ml = mm + nn
amx = qm*(.75 - dxn*dxn)
amy = .75 - dyn*dyn
mn = ml + nxv
dxl = qmh*(.5 - dxn)**2
dxp = qmh*(.5 + dxn)**2
mp = mn + nxv
dyl = .5*(.5 - dyn)**2
dyp = .5*(.5 + dyn)**2
c deposit charge
q(mn,l) = q(mn,l) + dxl*amy
q(mn+1,l) = q(mn+1,l) + amx*amy
q(mn+2,l) = q(mn+2,l) + dxp*amy
q(ml,l) = q(ml,l) + dxl*dyl
q(ml+1,l) = q(ml+1,l) + amx*dyl
q(ml+2,l) = q(ml+2,l) + dxp*dyl
q(mp,l) = q(mp,l) + dxl*dyp
q(mp+1,l) = q(mp+1,l) + amx*dyp
q(mp+2,l) = q(mp+2,l) + dxp*dyp
20 continue
return
end
c-----------------------------------------------------------------------
subroutine PSOST2X(part,q,npp,noff,nn,amxy,qm,nx,idimp,npmax,nblok
1,nxv,nxvyp,npd,nine)
c for 2d code, this subroutine calculates particle charge density
c using second-order spline interpolation, periodic boundaries,
c with short vectors over independent weights, and distributed data,
c as in j. schwartzmeier and t. hewitt, proc. 12th conf. on numerical
c simulation of plasmas, san francisco, ca, 1987.
c vectorized distributed version with 1d addressing
c 43 flops/particle, 29 loads, 27 stores
c input: all, output: q
c charge density is approximated by values at the nearest grid points
c q(n,m)=qm*(.75-dx**2)*(.75-dy**2)
c q(n+1,m)=.5*qm*((.5+dx)**2)*(.75-dy**2)
c q(n-1,m)=.5*qm*((.5-dx)**2)*(.75-dy**2)
c q(n,m+1)=.5*qm*(.75-dx**2)*(.5+dy)**2
c q(n+1,m+1)=.25*qm*((.5+dx)**2)*(.5+dy)**2
c q(n-1,m+1)=.25*qm*((.5-dx)**2)*(.5+dy)**2
c q(n,m-1)=.5*qm*(.75-dx**2)*(.5-dy)**2
c q(n+1,m-1)=.25*qm*((.5+dx)**2)*(.5-dy)**2
c q(n-1,m-1)=.25*qm*((.5-dx)**2)*(.5-dy)**2
c where n,m = nearest grid points and dx = x-n, dy = y-m
c part(1,n,l) = position x of particle n in partition l
c part(2,n,l) = position y of particle n in partition l
c q(j,k,l) = charge density at grid point (j,kk),
c where kk = k + noff(l) - 1
c npp(l) = number of particles in partition l
c noff(l) = lowermost global gridpoint in particle partition l.
c nn = scratch address array for vectorized charge deposition
c amxy = scratch weight array for vectorized charge deposition
c qm = charge on particle, in units of e
c nx = system length in x direction
c idimp = size of phase space = 4
c npmax = maximum number of particles in each partition
c nblok = number of particle partitions.
c nxv = first virtual dimension of charge array, must be >= nx
c nxvyp = nxv*nypmx, first actual dimension of charge array
c npd = size of scratch buffers for vectorized charge deposition
c nine = number of independent weights
dimension part(idimp,npmax,nblok), q(nxvyp,nblok)
dimension npp(nblok), noff(nblok)
dimension nn(nine,npd,nblok), amxy(nine,npd,nblok)
c parallel loop
do 50 l = 1, nblok
mnoff = noff(l) - 1
npb = npd
if (npp(l).gt.npd) then
ipp = float(npp(l) - 1)/float(npd) + 1.
else
ipp = 1
endif
c outer loop over blocks of particles
do 40 j = 1, ipp
jb = (j - 1)*npd
if (j.ge.ipp) npb = npp(l) - (ipp - 1)*npd
do 10 i = 1, npb
c find interpolation weights
n = part(1,i+jb,l) + .5
dxl = part(1,i+jb,l) - float(n)
n = n + 1
if (n.gt.nx) n = n - nx
amx = qm*(.75 - dxl*dxl)
np = n + 1
if (np.gt.nx) np = np - nx
dxp = .5*qm*(.5 + dxl)**2
nl = n - 1
if (nl.lt.1) nl = nl + nx
dxl = .5*qm*(.5 - dxl)**2
m = part(2,i+jb,l) + .5
dyl = part(2,i+jb,l) - float(m)
m = nxv*(m - mnoff)
amy = .75 - dyl*dyl
mp = m + nxv
dyp = .5*(.5 + dyl)**2
ml = m - nxv
dyl = .5*(.5 - dyl)**2
nn(1,i,l) = n + m
nn(2,i,l) = np + m
nn(3,i,l) = nl + m
nn(4,i,l) = n + mp
nn(5,i,l) = np + mp
nn(6,i,l) = nl + mp
nn(7,i,l) = n + ml
nn(8,i,l) = np + ml
nn(9,i,l) = nl + ml
amxy(1,i,l) = amx*amy
amxy(2,i,l) = dxp*amy
amxy(3,i,l) = dxl*amy
amxy(4,i,l) = amx*dyp
amxy(5,i,l) = dxp*dyp
amxy(6,i,l) = dxl*dyp
amxy(7,i,l) = amx*dyl
amxy(8,i,l) = dxp*dyl
amxy(9,i,l) = dxl*dyl
10 continue
c deposit charge
do 30 i = 1, npb
cdir$ ivdep
do 20 k = 1, 9
q(nn(k,i,l),l) = q(nn(k,i,l),l) + amxy(k,i,l)
20 continue
30 continue
40 continue
50 continue
return
end
c-----------------------------------------------------------------------
subroutine PGSOST2X(part,q,npp,noff,nn,amxy,qm,idimp,npmax,nblok,n
1xv,nxvyp,npd,nine)
c for 2d code, this subroutine calculates particle charge density
c using second-order spline interpolation, periodic boundaries,
c with short vectors over independent weights, and distributed data,
c as in j. schwartzmeier and t. hewitt, proc. 12th conf. on numerical
c simulation of plasmas, san francisco, ca, 1987.
c vectorized version with guard cells and 1d addressing
c 43 flops/particle, 29 loads, 27 stores
c input: all, output: q
c charge density is approximated by values at the nearest grid points
c q(n,m)=qm*(.75-dx**2)*(.75-dy**2)
c q(n+1,m)=.5*qm*((.5+dx)**2)*(.75-dy**2)
c q(n-1,m)=.5*qm*((.5-dx)**2)*(.75-dy**2)
c q(n,m+1)=.5*qm*(.75-dx**2)*(.5+dy)**2
c q(n+1,m+1)=.25*qm*((.5+dx)**2)*(.5+dy)**2
c q(n-1,m+1)=.25*qm*((.5-dx)**2)*(.5+dy)**2
c q(n,m-1)=.5*qm*(.75-dx**2)*(.5-dy)**2
c q(n+1,m-1)=.25*qm*((.5+dx)**2)*(.5-dy)**2
c q(n-1,m-1)=.25*qm*((.5-dx)**2)*(.5-dy)**2
c where n,m = nearest grid points and dx = x-n, dy = y-m
c part(1,n,l) = position x of particle n in partition l
c part(2,n,l) = position y of particle n in partition l
c q(j+1,k+1,l) = charge density at grid point (j,kk),
c where kk = k + noff(l) - 1
c npp(l) = number of particles in partition l
c noff(l) = lowermost global gridpoint in particle partition l.
c nn = scratch address array for vectorized charge deposition
c amxy = scratch weight array for vectorized charge deposition
c qm = charge on particle, in units of e
c idimp = size of phase space = 4
c npmax = maximum number of particles in each partition
c nblok = number of particle partitions.
c nxv = first virtual dimension of charge array, must be >= nx
c nxvyp = nxv*nypmx, first actual dimension of charge array
c npd = size of scratch buffers for vectorized charge deposition
c nine = number of independent weights
dimension part(idimp,npmax,nblok), q(nxvyp,nblok)
dimension npp(nblok), noff(nblok)
dimension nn(nine,npd,nblok), amxy(nine,npd,nblok)
qmh = .5*qm
c parallel loop
do 50 l = 1, nblok
mnoff = noff(l)
npb = npd
if (npp(l).gt.npd) then
ipp = float(npp(l) - 1)/float(npd) + 1.
else
ipp = 1
endif
c outer loop over blocks of particles
do 40 j = 1, ipp
jb = (j - 1)*npd
if (j.ge.ipp) npb = npp(l) - (ipp - 1)*npd
do 10 i = 1, npb
c find interpolation weights
n = part(1,i+jb,l) + .5
m = part(2,i+jb,l) + .5
dxp = part(1,i+jb,l) - float(n)
dyp = part(2,i+jb,l) - float(m)
n = n + 1
m = nxv*(m - mnoff)
amx = qm*(.75 - dxp*dxp)
amy = .75 - dyp*dyp
ml = m + n
dxl = qmh*(.5 - dxp)**2
dxp = qmh*(.5 + dxp)**2
mn = ml + nxv
dyl = .5*(.5 - dyp)**2
dyp = .5*(.5 + dyp)**2
mp = mn + nxv
nn(1,i,l) = mn
nn(2,i,l) = mn + 1
nn(3,i,l) = mn + 2
nn(4,i,l) = ml
nn(5,i,l) = ml + 1
nn(6,i,l) = ml + 2
nn(7,i,l) = mp
nn(8,i,l) = mp + 1
nn(9,i,l) = mp + 2
amxy(1,i,l) = dxl*amy
amxy(2,i,l) = amx*amy
amxy(3,i,l) = dxp*amy
amxy(4,i,l) = dxl*dyl
amxy(5,i,l) = amx*dyl
amxy(6,i,l) = dxp*dyl
amxy(7,i,l) = dxl*dyp
amxy(8,i,l) = amx*dyp
amxy(9,i,l) = dxp*dyp
10 continue
c deposit charge
do 30 i = 1, npb
cdir$ ivdep
do 20 k = 1, 9
q(nn(k,i,l),l) = q(nn(k,i,l),l) + amxy(k,i,l)
20 continue
30 continue
40 continue
50 continue
return
end
c-----------------------------------------------------------------------
subroutine PDOST2L(part,q,npp,noff,qm,nx,idimp,npmax,nblok,nxv,nyp
1mx)
c for 2d code, this subroutine calculates particle charge density
c using first-order linear interpolation, periodic boundaries
c and distributed data.
c baseline scalar distributed version
c 17 flops/particle, 6 loads, 4 stores
c input: all, output: q
c charge density is approximated by values at the nearest grid points
c q(n,m)=qm*(1.-dx)*(1.-dy)
c q(n+1,m)=qm*dx*(1.-dy)
c q(n,m+1)=qm*(1.-dx)*dy
c q(n+1,m+1)=qm*dx*dy
c where n,m = leftmost grid points and dx = x-n, dy = y-m
c part(1,n,l) = position x of particle n in partition l
c part(2,n,l) = position y of particle n in partition l
c q(j,k,l) = charge density at grid point (j,kk),
c where kk = k + noff(l) - 1
c npp(l) = number of particles in partition l
c noff(l) = lowermost global gridpoint in particle partition l.
c qm = charge on particle, in units of e
c nx = system length in x direction
c idimp = size of phase space = 4
c npmax = maximum number of particles in each partition
c nblok = number of particle partitions.
c nxv = first dimension of charge array, must be >= nx
c nypmx = maximum size of particle partition, including guard cells.
dimension part(idimp,npmax,nblok), q(nxv,nypmx,nblok)
dimension npp(nblok), noff(nblok)
do 20 l = 1, nblok
mnoff = noff(l) - 1
do 10 j = 1, npp(l)
c find interpolation weights
nn = part(1,j,l)
mm = part(2,j,l)
dxp = qm*(part(1,j,l) - float(nn))
dyp = part(2,j,l) - float(mm)
nn = nn + 1
mm = mm - mnoff
amx = qm - dxp
np = nn + 1
if (np.gt.nx) np = np - nx
amy = 1. - dyp
mp = mm + 1
c deposit charge
q(nn,mm,l) = q(nn,mm,l) + amx*amy
q(np,mm,l) = q(np,mm,l) + dxp*amy
q(nn,mp,l) = q(nn,mp,l) + amx*dyp
q(np,mp,l) = q(np,mp,l) + dxp*dyp
10 continue
20 continue
return
end
c-----------------------------------------------------------------------
subroutine PGPOST2L(part,q,npp,noff,qm,idimp,npmax,nblok,nxv,nypmx
1)
c for 2d code, this subroutine calculates particle charge density
c using first-order linear interpolation, periodic boundaries
c and distributed data.
c scalar version using guard cells, for distributed data
c 17 flops/particle, 6 loads, 4 stores
c input: all, output: q
c charge density is approximated by values at the nearest grid points
c q(n,m)=qm*(1.-dx)*(1.-dy)
c q(n+1,m)=qm*dx*(1.-dy)
c q(n,m+1)=qm*(1.-dx)*dy
c q(n+1,m+1)=qm*dx*dy
c where n,m = leftmost grid points and dx = x-n, dy = y-m
c part(1,n,l) = position x of particle n in partition l
c part(2,n,l) = position y of particle n in partition l
c q(j,k,l) = charge density at grid point (j,kk),
c where kk = k + noff(l) - 1
c npp(l) = number of particles in partition l
c noff(l) = lowermost global gridpoint in particle partition l.
c qm = charge on particle, in units of e
c idimp = size of phase space = 4
c npmax = maximum number of particles in each partition
c nblok = number of particle partitions.
c nxv = first dimension of charge array, must be >= nx+1
c nypmx = maximum size of particle partition, including guard cells.
dimension part(idimp,npmax,nblok), q(nxv,nypmx,nblok)
dimension npp(nblok), noff(nblok)
do 20 l = 1, nblok
mnoff = noff(l) - 1
do 10 j = 1, npp(l)
c find interpolation weights
nn = part(1,j,l)
mm = part(2,j,l)
dxp = qm*(part(1,j,l) - float(nn))
dyp = part(2,j,l) - float(mm)
nn = nn + 1
mm = mm - mnoff
amx = qm - dxp
mp = mm + 1
amy = 1. - dyp
np = nn + 1
c deposit charge
q(np,mp,l) = q(np,mp,l) + dxp*dyp
q(nn,mp,l) = q(nn,mp,l) + amx*dyp
q(np,mm,l) = q(np,mm,l) + dxp*amy
q(nn,mm,l) = q(nn,mm,l) + amx*amy
10 continue
20 continue
return
end
c-----------------------------------------------------------------------
subroutine PGSPOST2L(part,q,npp,noff,qm,idimp,npmax,nblok,nxv,nxyp
1)
c for 2d code, this subroutine calculates particle charge density
c using first-order linear interpolation, periodic boundaries
c and distributed data.
c scalar version using guard cells, integer conversion precalculation,
c and 1d addressing, for distributed data
c cases 9-10 in v.k.decyk et al, computers in physics 10, 290 (1996).
c 17 flops/particle, 6 loads, 4 stores
c input: all, output: q
c charge density is approximated by values at the nearest grid points
c q(n,m)=qm*(1.-dx)*(1.-dy)
c q(n+1,m)=qm*dx*(1.-dy)
c q(n,m+1)=qm*(1.-dx)*dy
c q(n+1,m+1)=qm*dx*dy
c where n,m = leftmost grid points and dx = x-n, dy = y-m
c part(1,n,l) = position x of particle n in partition l
c part(2,n,l) = position y of particle n in partition l
c q(j,k,l) = charge density at grid point (j,kk),
c where kk = k + noff(l) - 1
c npp(l) = number of particles in partition l
c noff(l) = lowermost global gridpoint in particle partition l.
c qm = charge on particle, in units of e
c idimp = size of phase space = 4
c npmax = maximum number of particles in each partition
c nblok = number of particle partitions.
c nxv = first dimension of charge array, must be >= nx+1
c nxyp = actual first dimension of charge array, must be >= nxv*nypmx
dimension part(idimp,npmax,nblok), q(nxyp,nblok)
dimension npp(nblok), noff(nblok)
do 20 l = 1, nblok
if (npp(l).lt.1) go to 20
mnoff = noff(l)
c begin first particle
nnn = part(1,1,l)
mmn = part(2,1,l)
dxn = part(1,1,l) - float(nnn)
dyn = part(2,1,l) - float(mmn)
mmn = mmn - mnoff
do 10 j = 2, npp(l)
c find interpolation weights
nn = nnn + 1
mm = nxv*mmn
nnn = part(1,j,l)
mmn = part(2,j,l)
dxp = qm*dxn
dyp = dyn
dxn = part(1,j,l) - float(nnn)
dyn = part(2,j,l) - float(mmn)
mm = mm + nn
amx = qm - dxp
mp = mm + nxv
amy = 1. - dyp
mmn = mmn - mnoff
c deposit charge
dx1 = q(mp+1,l) + dxp*dyp
dyp = q(mp,l) + amx*dyp
dxp = q(mm+1,l) + dxp*amy
amy = q(mm,l) + amx*amy
q(mp+1,l) = dx1
q(mp,l) = dyp
q(mm+1,l) = dxp
q(mm,l) = amy
10 continue
c deposit charge for last particle
nn = nnn + 1
mm = nxv*mmn
dxp = qm*dxn
mm = mm + nn
amx = qm - dxp
mp = mm + nxv
amy = 1. - dyn
c deposit charge
q(mp+1,l) = q(mp+1,l) + dxp*dyn
q(mp,l) = q(mp,l) + amx*dyn
q(mm+1,l) = q(mm+1,l) + dxp*amy
q(mm,l) = q(mm,l) + amx*amy
20 continue
return
end
c-----------------------------------------------------------------------
subroutine PSOST2XL(part,q,npp,noff,nn,amxy,qm,nx,idimp,npmax,nblo
1k,nxv,nxvyp,npd,ifour)
c for 2d code, this subroutine calculates particle charge density
c using first-order linear interpolation, periodic boundaries,
c with short vectors over independent weights, and distributed data,
c as in j. schwartzmeier and t. hewitt, proc. 12th conf. on numerical
c simulation of plasmas, san francisco, ca, 1987.
c vectorized distributed version with 1d addressing
c 17 flops/particle, 14 loads, 12 stores
c input: all, output: q
c charge density is approximated by values at the nearest grid points
c q(n,m)=qm*(1.-dx)*(1.-dy)
c q(n+1,m)=qm*dx*(1.-dy)
c q(n,m+1)=qm*(1.-dx)*dy
c q(n+1,m+1)=qm*dx*dy
c where n,m = leftmost grid points and dx = x-n, dy = y-m
c part(1,n,l) = position x of particle n in partition l
c part(2,n,l) = position y of particle n in partition l
c q(j,k,l) = charge density at grid point (j,kk),
c where kk = k + noff(l) - 1
c npp(l) = number of particles in partition l
c noff(l) = lowermost global gridpoint in particle partition l.
c nn = scratch address array for vectorized charge deposition
c amxy = scratch weight array for vectorized charge deposition
c qm = charge on particle, in units of e
c nx = system length in x direction
c idimp = size of phase space = 4
c npmax = maximum number of particles in each partition
c nblok = number of particle partitions.
c nxv = first virtual dimension of charge array, must be >= nx
c nxvyp = nxv*nypmx, first actual dimension of charge array
c npd = size of scratch buffers for vectorized charge deposition
c ifour = number of independent weights
dimension part(idimp,npmax,nblok), q(nxvyp,nblok)
dimension npp(nblok), noff(nblok)
dimension nn(ifour,npd,nblok), amxy(ifour,npd,nblok)
c parallel loop
do 50 l = 1, nblok
mnoff = noff(l)
npb = npd
if (npp(l).gt.npd) then
ipp = float(npp(l) - 1)/float(npd) + 1.
else
ipp = 1
endif
c outer loop over blocks of particles
do 40 j = 1, ipp
jb = (j - 1)*npd
if (j.ge.ipp) npb = npp(l) - (ipp - 1)*npd
do 10 i = 1, npb
c find interpolation weights
n = part(1,i+jb,l)
dxp = qm*(part(1,i+jb,l) - float(n))
n = n + 1
amx = qm - dxp
np = n + 1
if (np.gt.nx) np = np - nx
m = part(2,i+jb,l)
dyp = part(2,i+jb,l) - float(m)
m = nxv*(m - mnoff)
amy = 1. - dyp
mp = m + nxv
nn(1,i,l) = n + m
nn(2,i,l) = np + m
nn(3,i,l) = n + mp
nn(4,i,l) = np + mp
amxy(1,i,l) = amx*amy
amxy(2,i,l) = dxp*amy
amxy(3,i,l) = amx*dyp
amxy(4,i,l) = dxp*dyp
10 continue
c deposit charge
do 30 i = 1, npb
cdir$ ivdep
do 20 k = 1, 4
q(nn(k,i,l),l) = q(nn(k,i,l),l) + amxy(k,i,l)
20 continue
30 continue
40 continue
50 continue
return
end
c-----------------------------------------------------------------------
subroutine PGSOST2XL(part,q,npp,noff,nn,amxy,qm,idimp,npmax,nblok,
1nxv,nxvyp,npd,ifour)
c for 2d code, this subroutine calculates particle charge density
c using first-order linear interpolation, periodic boundaries,
c with short vectors over independent weights, and distributed data,
c as in j. schwartzmeier and t. hewitt, proc. 12th conf. on numerical
c simulation of plasmas, san francisco, ca, 1987.
c vectorized distributed version with guard cells and 1d addressing
c 17 flops/particle, 14 loads, 12 stores
c input: all, output: q
c charge density is approximated by values at the nearest grid points
c q(n,m)=qm*(1.-dx)*(1.-dy)
c q(n+1,m)=qm*dx*(1.-dy)
c q(n,m+1)=qm*(1.-dx)*dy
c q(n+1,m+1)=qm*dx*dy
c where n,m = leftmost grid points and dx = x-n, dy = y-m
c part(1,n,l) = position x of particle n in partition l
c part(2,n,l) = position y of particle n in partition l
c q(j,k,l) = charge density at grid point (j,kk),
c where kk = k + noff(l) - 1
c npp(l) = number of particles in partition l
c noff(l) = lowermost global gridpoint in particle partition l.
c nn = scratch address array for vectorized charge deposition
c amxy = scratch weight array for vectorized charge deposition
c qm = charge on particle, in units of e
c idimp = size of phase space = 4
c npmax = maximum number of particles in each partition
c nblok = number of particle partitions.
c nxv = first virtual dimension of charge array, must be >= nx+1
c nxvyp = nxv*nypmx, first actual dimension of charge array
c npd = size of scratch buffers for vectorized charge deposition
c ifour = number of independent weights
dimension part(idimp,npmax,nblok), q(nxvyp,nblok)
dimension npp(nblok), noff(nblok)
dimension nn(ifour,npd,nblok), amxy(ifour,npd,nblok)
c parallel loop
do 50 l = 1, nblok
mnoff = noff(l)
npb = npd
if (npp(l).gt.npd) then
ipp = float(npp(l) - 1)/float(npd) + 1.
else
ipp = 1
endif
c outer loop over blocks of particles
do 40 j = 1, ipp
jb = (j - 1)*npd
if (j.ge.ipp) npb = npp(l) - (ipp - 1)*npd
do 10 i = 1, npb
c find interpolation weights
n = part(1,i+jb,l)
m = part(2,i+jb,l)
dxp = qm*(part(1,i+jb,l) - float(n))
dyp = part(2,i+jb,l) - float(m)
n = n + 1
mm = nxv*(m - mnoff)
amx = qm - dxp
mm = mm + n
amy = 1. - dyp
mp = mm + nxv
nn(4,i,l) = mm
nn(3,i,l) = mm + 1
nn(2,i,l) = mp
nn(1,i,l) = mp + 1
amxy(1,i,l) = dxp*dyp
amxy(2,i,l) = amx*dyp
amxy(3,i,l) = dxp*amy
amxy(4,i,l) = amx*amy
10 continue
c deposit charge
do 30 i = 1, npb
cdir$ ivdep
do 20 k = 1, 4
q(nn(k,i,l),l) = q(nn(k,i,l),l) + amxy(k,i,l)
20 continue
30 continue
40 continue
50 continue
return
end
c-----------------------------------------------------------------------
subroutine PPUSH2(part,fx,fy,npp,noff,qbm,dt,ek,nx,idimp,npmax,nbl
1ok,nxv,nypmx)
c for 2d code, this subroutine updates particle co-ordinates and
c velocities using leap-frog scheme in time and second-order spline
c interpolation in space, with periodic boundary conditions,
c for distributed data.
c baseline scalar distributed version
c 80 flops/particle, 22 loads, 4 stores
c input: all, output: part, ek
c equations used are:
c vx(t+dt/2) = vx(t-dt/2) + (q/m)*fx(x(t),y(t))*dt,
c vy(t+dt/2) = vy(t-dt/2) + (q/m)*fy(x(t),y(t))*dt,
c where q/m is charge/mass, and
c x(t+dt) = x(t) + vx(t+dt/2)*dt, y(t+dt) = y(t) + vy(t+dt/2)*dt
c fx(x(t),y(t)) and fy(x(t),y(t)) are approximated by interpolation from
c the nearest grid points:
c fx(x,y) = (.75-dy**2)*((.75-dx**2)*fx(n,m)+(.5*(.5+dx)**2)*fx(n+1,m)+
c (.5*(.5-dx)**2)*fx(n-1,m)) + (.5*(.5+dy)**2)*((.75-dx**2)*fx(n,m+1)+
c (.5*(.5+dx)**2)*fx(n+1,m+1)+(.5*(.5-dx)**2)*fx(n-1,m+1)) +
c (.5*(.5-dy)**2)*((.75-dx**2)*fx(n,m-1)+(.5*(.5+dx)**2)*fx(n+1,m-1)+
c (.5*(.5-dx)**2)*fx(n-1,m-1))
c fy(x,y) = (.75-dy**2)*((.75-dx**2)*fy(n,m)+(.5*(.5+dx)**2)*fy(n+1,m)+
c (.5*(.5-dx)**2)*fy(n-1,m)) + (.5*(.5+dy)**2)*((.75-dx**2)*fy(n,m+1)+
c (.5*(.5+dx)**2)*fy(n+1,m+1)+(.5*(.5-dx)**2)*fy(n-1,m+1)) +
c (.5*(.5-dy)**2)*((.75-dx**2)*fy(n,m-1)+(.5*(.5+dx)**2)*fy(n+1,m-1)+
c (.5*(.5-dx)**2)*fy(n-1,m-1))
c where n,m = nearest grid points and dx = x-n, dy = y-m
c part(1,n,l) = position x of particle n in partition l
c part(2,n,l) = position y of particle n in partition l
c part(3,n,l) = velocity vx of particle n in partition l
c part(4,n,l) = velocity vy of particle n in partition l
c fx(j,k,l) = x component of force/charge at grid (j,kk)
c fy(j,k,l) = y component of force/charge at grid (j,kk)
c in other words, fx/fy are the convolutions of the electric field
c over the particle shape, where kk = k + noff(l) - 1
c npp(l) = number of particles in partition l
c noff(l) = lowermost global gridpoint in particle partition l.
c qbm = particle charge/mass ratio
c dt = time interval between successive calculations
c kinetic energy/mass at time t is also calculated, using
c ek = .125*sum((vx(t+dt/2)+vx(t-dt/2))**2+(vy(t+dt/2)+vy(t-dt/2))**2)
c nx = system length in x direction
c idimp = size of phase space = 4
c npmax = maximum number of particles in each partition
c nblok = number of particle partitions.
c nxv = first dimension of field arrays, must be >= nx
c nypmx = maximum size of particle partition, including guard cells.
double precision sum1
dimension part(idimp,npmax,nblok)
dimension fx(nxv,nypmx,nblok), fy(nxv,nypmx,nblok)
dimension npp(nblok), noff(nblok)
zero = 0.
anx = float(nx)
qtm = qbm*dt
sum1 = 0.0d0
do 20 l = 1, nblok
mnoff = noff(l) - 2
do 10 j = 1, npp(l)
c find interpolation weights
nn = part(1,j,l) + .5
mm = part(2,j,l) + .5
dxp = part(1,j,l) - float(nn)
dyp = part(2,j,l) - float(mm)
nl = nn
if (nl.lt.1) nl = nl + nx
mm = mm - mnoff
amx = .75 - dxp*dxp
amy = .75 - dyp*dyp
nn = nn + 1
if (nn.gt.nx) nn = nn - nx
dxl = .5*(.5 - dxp)**2
np = nn + 1
if (np.gt.nx) np = np - nx
dxp = .5*(.5 + dxp)**2
ml = mm - 1
dyl = .5*(.5 - dyp)**2
mp = mm + 1
dyp = .5*(.5 + dyp)**2
c find acceleration
dx = amy*(dxl*fx(nl,mm,l) + amx*fx(nn,mm,l) + dxp*fx(np,mm,l)) + d
1yl*(dxl*fx(nl,ml,l) + amx*fx(nn,ml,l) + dxp*fx(np,ml,l)) + dyp*(dx
2l*fx(nl,mp,l) + amx*fx(nn,mp,l) + dxp*fx(np,mp,l))
dy = amy*(dxl*fy(nl,mm,l) + amx*fy(nn,mm,l) + dxp*fy(np,mm,l)) + d
1yl*(dxl*fy(nl,ml,l) + amx*fy(nn,ml,l) + dxp*fy(np,ml,l)) + dyp*(dx
2l*fy(nl,mp,l) + amx*fy(nn,mp,l) + dxp*fy(np,mp,l))
c new velocity
dx = part(3,j,l) + qtm*dx
dy = part(4,j,l) + qtm*dy
c average kinetic energy
sum1 = sum1 + (dx + part(3,j,l))**2 + (dy + part(4,j,l))**2
part(3,j,l) = dx
part(4,j,l) = dy
c new position
dx = part(1,j,l) + dx*dt
dy = part(2,j,l) + dy*dt
c periodic boundary conditions
if (dx.lt.zero) dx = dx + anx
if (dx.ge.anx) dx = dx - anx
part(1,j,l) = dx
part(2,j,l) = dy
10 continue
20 continue
c normalize kinetic energy
ek = ek + .125*sum1
return
end
c-----------------------------------------------------------------------
subroutine PGPUSH2(part,fxy,npp,noff,qbm,dt,ek,nx,ny,idimp,npmax,n
1blok,nxv,nypmx,ipbc)
c for 2d code, this subroutine updates particle co-ordinates and
c velocities using leap-frog scheme in time and second-order spline
c interpolation in space, with various boundary conditions,
c for distributed data.
c scalar version using guard cells, for distributed data
c 80 flops/particle, 22 loads, 4 stores
c input: all, output: part, ek
c equations used are:
c vx(t+dt/2) = vx(t-dt/2) + (q/m)*fx(x(t),y(t))*dt,
c vy(t+dt/2) = vy(t-dt/2) + (q/m)*fy(x(t),y(t))*dt,
c where q/m is charge/mass, and
c x(t+dt) = x(t) + vx(t+dt/2)*dt, y(t+dt) = y(t) + vy(t+dt/2)*dt
c fx(x(t),y(t)) and fy(x(t),y(t)) are approximated by interpolation from
c the nearest grid points:
c fx(x,y) = (.75-dy**2)*((.75-dx**2)*fx(n,m)+(.5*(.5+dx)**2)*fx(n+1,m)+
c (.5*(.5-dx)**2)*fx(n-1,m)) + (.5*(.5+dy)**2)*((.75-dx**2)*fx(n,m+1)+
c (.5*(.5+dx)**2)*fx(n+1,m+1)+(.5*(.5-dx)**2)*fx(n-1,m+1)) +
c (.5*(.5-dy)**2)*((.75-dx**2)*fx(n,m-1)+(.5*(.5+dx)**2)*fx(n+1,m-1)+
c (.5*(.5-dx)**2)*fx(n-1,m-1))
c fy(x,y) = (.75-dy**2)*((.75-dx**2)*fy(n,m)+(.5*(.5+dx)**2)*fy(n+1,m)+
c (.5*(.5-dx)**2)*fy(n-1,m)) + (.5*(.5+dy)**2)*((.75-dx**2)*fy(n,m+1)+
c (.5*(.5+dx)**2)*fy(n+1,m+1)+(.5*(.5-dx)**2)*fy(n-1,m+1)) +
c (.5*(.5-dy)**2)*((.75-dx**2)*fy(n,m-1)+(.5*(.5+dx)**2)*fy(n+1,m-1)+
c (.5*(.5-dx)**2)*fy(n-1,m-1))
c where n,m = nearest grid points and dx = x-n, dy = y-m
c part(1,n,l) = position x of particle n in partition l
c part(2,n,l) = position y of particle n in partition l
c part(3,n,l) = velocity vx of particle n in partition l
c part(4,n,l) = velocity vy of particle n in partition l
c fxy(1,j+1,k,l) = x component of force/charge at grid (j,kk)
c fxy(2,j+1,k,l) = y component of force/charge at grid (j,kk)
c in other words, fxy are the convolutions of the electric field
c over the particle shape, where kk = k + noff(l) - 1
c npp(l) = number of particles in partition l
c noff(l) = lowermost global gridpoint in particle partition l.
c qbm = particle charge/mass ratio