-
Notifications
You must be signed in to change notification settings - Fork 11
/
compute_hist.f
54 lines (39 loc) · 1.21 KB
/
compute_hist.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
*----------------------------------------------------------------------*
* COMPILE USING
* f2py -m rhocompute -c compute_rho.f
subroutine compute_hist(N_mp,x_mp,wei_mp, bias_x,
+ Dx, Nxg, hist)
Cf2py intent(in) N_mp
Cf2py intent(in) x_mp
Cf2py intent(in) wei_mp
Cf2py intent(in) bias_x
Cf2py intent(in) Dx
Cf2py intent(in) Nxg
Cf2py intent(inout) hist
implicit none
integer N_mp
real*8 x_mp(N_mp), wei_mp(N_mp)
real*8 bias_x, Dx
integer Nxg
real*8 hist(Nxg)
integer p
real*8 wei_mp_curr, fi, hx
integer i
!write(*,*) 'ciao fortran'
do p=1,N_mp
!loop over particles
fi = 1+(x_mp(p)-bias_x)/Dx; !real i index of particle's cell
i = int(fi); !integral part
hx = fi-dble(i); !the remainder
wei_mp_curr=wei_mp(p);
!interpolate charge to nodes
!write (*,*) 'Nxg=', Nxg
!write (*,*) 'i=', i
if (i<Nxg) then
hist(i) = hist(i) + wei_mp_curr*(1-hx);
hist(i+1) = hist(i+1) + wei_mp_curr*hx;
else
hist(Nxg)=hist(Nxg)+ wei_mp_curr
end if
end do
end subroutine