mergebloubs boilerplate done

This commit is contained in:
tth
2022-02-16 15:59:42 +01:00
parent d9491cc5f9
commit b26618a841
7 changed files with 58 additions and 25 deletions

View File

@@ -15,7 +15,7 @@ module bloubspace
real :: px, py, pz
real :: vx, vy, vz
real :: radius
integer :: seq
integer :: age
end type t_bloubs
contains ! -----------------------------------------
@@ -47,8 +47,9 @@ module bloubspace
else
life = "dead"
endif
write (0, '(4X, A)') '+------------ ' // message
write (0, '(4X,A3,A8,2X,I6,4X,A5)') '| ', blb%nick, blb%num, life
write (0, '(4X, A)') '+--------------- ' // message // " -------"
write (0, '(4X,A3,A8,2X,I6,4X,A5,4X,I5)') '| ', &
blb%nick, blb%num, life, blb%age
write (0, '(4X,A3,3X,3(F8.3, 4X))') '| P', blb%px, blb%py, blb%pz
write (0, '(4X,A3,3X,3(F8.3, 4X))') '| V', blb%vx, blb%vy, blb%vz
write (0, '()')
@@ -74,42 +75,59 @@ module bloubspace
if (5.0 .lt. blb%px) then
blb%vx = -1.0 * blb%vx
blb%px = 5.0
blb%seq = blb%seq + 1
blb%age = blb%age + 1
endif
if (-5.0 .gt. blb%px) then
blb%vx = -1.0 * blb%vx
blb%px = -5.0
blb%seq = blb%seq + 1
blb%age = blb%age + 1
endif
if (0.0 .gt. blb%py) then
blb%vy = -1.0 * blb%vy
blb%py = 0.0
blb%seq = blb%seq + 1
blb%age = blb%age + 1
endif
if (5.0 .lt. blb%py) then
blb%vy = -1.0 * blb%vy
blb%seq = blb%seq + 1
blb%age = blb%age + 1
blb%py = 5.0
endif
if (5.0 .lt. blb%pz) then
blb%vz = -1.0 * blb%vz
blb%seq = blb%seq + 1
blb%age = blb%age + 1
blb%pz = 5.0
endif
if (-5.0 .gt. blb%pz) then
blb%vz = -1.0 * blb%vz
blb%seq = blb%seq + 1
blb%age = blb%age + 1
blb%pz = -5.0
endif
end subroutine
! ----------------------------------------------------------------
function distance_of_bloubs(bla, blb)
type(t_bloubs), intent(in) :: bla, blb
real :: distance_of_bloubs
real :: dx, dy, dz
dx = (bla%px-blb%px)**2
dy = (bla%py-blb%py)**2
dz = (bla%pz-blb%pz)**2
distance_of_bloubs = sqrt(dx + dy +dz)
end function
! ----------------------------------------------------------------
! kill a bloub under condition(s)
subroutine green_soylent (blb)
type(t_bloubs), intent (inout) :: blb
if (blb%seq .gt. 6) then
if (blb%age .gt. 5) then
blb%alive = .FALSE.
endif
end subroutine