moved a function

This commit is contained in:
tTh 2022-11-30 03:24:24 +01:00
parent 67c606db47
commit c3c6caafb8
2 changed files with 33 additions and 32 deletions

View File

@ -1,7 +1,7 @@
!-----------------------------------------------------------------------
!
! project "gravity field"
!
!-
! test program for the project "gravity field"
!-
!-----------------------------------------------------------------------
program essai
use realfield
@ -64,33 +64,6 @@ subroutine build_and_write_a_field(szx, szy, moon, fname)
end subroutine
!-----------------------------------------------------------------------
!-
! Compute the gravity field in a pre-allocated array relative
! to the massbody 'moon'. Nobody know where the magic number
! come from, sorry.
!-
subroutine compute_a_field(field, moon)
real, dimension(:,:), intent(out) :: field
type(massbody), intent(in) :: moon
integer :: ix, iy
real :: fx, fy
real :: grav
! print *, "pic size ", ubound(field, 1), "W", ubound(field, 2), "H"
! print *, "mass body ", moon
do ix=1, ubound(field, 1)
fx = real(ix)
do iy=1, ubound(field, 2)
fy = real(iy)
grav = compute_gravity(fx, fy, moon)
field(ix,iy) = grav
enddo
enddo
end subroutine
!-----------------------------------------------------------------------
!-----------------------------------------------------------------------

View File

@ -36,6 +36,34 @@ function compute_gravity(fx, fy, body)
end function
!-----------------------------------------------------------------------
!-
! Compute the gravity field in a pre-allocated array relative
! to the massbody 'moon'. Nobody know where the magic number
! come from, sorry.
!-
subroutine compute_a_field(field, moon)
real, dimension(:,:), intent(out) :: field
type(massbody), intent(in) :: moon
integer :: ix, iy
real :: fx, fy
real :: grav
! print *, "pic size ", ubound(field, 1), "W", ubound(field, 2), "H"
! print *, "mass body ", moon
do ix=1, ubound(field, 1)
fx = real(ix)
do iy=1, ubound(field, 2)
fy = real(iy)
grav = compute_gravity(fx, fy, moon)
field(ix,iy) = grav
enddo
enddo
end subroutine
!-----------------------------------------------------------------------
!-----------------------------------------------------------------------
end module