From c3c6caafb85ad93f0fda8c3f99609a6e97c3396e Mon Sep 17 00:00:00 2001 From: tTh Date: Wed, 30 Nov 2022 03:24:24 +0100 Subject: [PATCH] moved a function --- GravityField/essai.f90 | 37 +++++-------------------------------- GravityField/realfield.f90 | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/GravityField/essai.f90 b/GravityField/essai.f90 index 6e156b4..3858c1e 100644 --- a/GravityField/essai.f90 +++ b/GravityField/essai.f90 @@ -1,7 +1,7 @@ !----------------------------------------------------------------------- -! -! project "gravity field" -! +!- +! test program for the project "gravity field" +!- !----------------------------------------------------------------------- program essai use realfield @@ -11,7 +11,7 @@ program essai type(massbody) :: planet integer :: foo - character (len=100) :: filename + character(len=100) :: filename planet%posx = 337.314 planet%posy = 164.666 @@ -35,7 +35,7 @@ contains subroutine build_and_write_a_field(szx, szy, moon, fname) integer, intent(in) :: szx, szy type(massbody), intent(in) :: moon - character (len=*), intent(in) :: fname + character(len=*), intent(in) :: fname real :: maxi, mini integer :: errcode @@ -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 !----------------------------------------------------------------------- !----------------------------------------------------------------------- diff --git a/GravityField/realfield.f90 b/GravityField/realfield.f90 index 233a6ac..1c32872 100644 --- a/GravityField/realfield.f90 +++ b/GravityField/realfield.f90 @@ -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