63 lines
1.2 KiB
Fortran
63 lines
1.2 KiB
Fortran
program essai
|
|
implicit none
|
|
|
|
integer :: ix, iy
|
|
real :: fx, fy
|
|
real :: foo, bar, maxi, mini
|
|
|
|
maxi = 0.0
|
|
mini = 9e9
|
|
|
|
do ix=1, 2000
|
|
fx = real(ix)
|
|
do iy=1, 2000
|
|
fy = real(iy)
|
|
|
|
foo = rdist(fx, fy, 222.22, 765.432)
|
|
bar = gravity(foo, 1337.0)
|
|
|
|
maxi = max(maxi, bar)
|
|
mini = min(mini, bar)
|
|
|
|
enddo
|
|
enddo
|
|
|
|
print *, "dist : ", mini, maxi
|
|
|
|
contains !------------------------------------------
|
|
|
|
function gravity(distance, masse)
|
|
real, intent(in) :: distance, masse
|
|
real :: gravity
|
|
real :: computed
|
|
|
|
if (distance .LT. 0.010) then
|
|
computed = 0.0
|
|
else
|
|
computed = masse / (distance ** 2)
|
|
endif
|
|
|
|
gravity = computed
|
|
|
|
end function
|
|
|
|
!------------------------------------------
|
|
|
|
function rdist(ax, ay, bx, by)
|
|
real, intent(in) :: ax, ay, bx, by
|
|
real :: rdist
|
|
real :: rx, ry
|
|
|
|
rx = real(ax-bx)
|
|
ry = real(ay-by)
|
|
|
|
rdist = sqrt( (rx*rx) + (ry*ry) )
|
|
|
|
end function
|
|
|
|
|
|
!------------------------------------------
|
|
!------------------------------------------
|
|
|
|
end program
|