function Grav(X,M)
|
C accepts positions of particles X and masses of particles M
|
C returns accelerations in Grav
|
C Uses completely parallel calculation, ignoring anti-symmetry of force
-
integer, parameter :: N =number of particles
-
real, parameter :: G = gravitational constant
-
real array (1:3, 1:N) :: X,M,Grav
|
! calculates acceleration on body i due to body j in entries ( :,i,j )
-
real array (1:3, 1:N,1:N) :: A, Xi, Xj, Ms, D, R
-
logical, array (1:3, 1:N,1:N) ::diag
-
integer i,j,k
|
! diag is true for diagonal of N by N slices
-
forall ( k=1:3, i=1:N, j=1:N ) diag = (i.eq.j)
|