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 program essai
use realfield use realfield
@ -11,7 +11,7 @@ program essai
type(massbody) :: planet type(massbody) :: planet
integer :: foo integer :: foo
character (len=100) :: filename character(len=100) :: filename
planet%posx = 337.314 planet%posx = 337.314
planet%posy = 164.666 planet%posy = 164.666
@ -35,7 +35,7 @@ contains
subroutine build_and_write_a_field(szx, szy, moon, fname) subroutine build_and_write_a_field(szx, szy, moon, fname)
integer, intent(in) :: szx, szy integer, intent(in) :: szx, szy
type(massbody), intent(in) :: moon type(massbody), intent(in) :: moon
character (len=*), intent(in) :: fname character(len=*), intent(in) :: fname
real :: maxi, mini real :: maxi, mini
integer :: errcode integer :: errcode
@ -64,33 +64,6 @@ subroutine build_and_write_a_field(szx, szy, moon, fname)
end subroutine 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 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 end module