Fortraneries/GravityField/essai.f90
2022-11-28 13:47:44 +01:00

55 lines
1.2 KiB
Fortran

!
! project "gravity field"
!
program essai
use realfield
implicit none
type(massbody) :: planet
integer :: foo
planet%posx = 1337.314
planet%posy = 1664.666
planet%mass = 1e4
do foo=1, 10
call build_a_field(800, 600, planet)
planet%posy = planet%posy + 51.45
enddo
STOP 'YOLO'
contains !------------------------------------------
!
subroutine build_a_field(szx, szy, moon)
integer, intent(in) :: szx, szy
type(massbody), intent(in) :: moon
integer :: ix, iy
real :: fx, fy
real :: grav, maxi, mini
integer :: errcode
real, dimension(:,:), allocatable :: field
allocate(field(szx, szy), stat=errcode)
do ix=1, szx
fx = real(ix)
do iy=1, szy
fy = real(iy)
grav = compute_gravity(ix, iy, moon) / 2180800.0
field(ix,iy) = grav
enddo
enddo
maxi = maxval(field)
mini = minval(field)
print *, "field: ", mini, maxi, maxi-mini
deallocate(field)
end subroutine
!------------------------------------------
end program