2022-02-07 09:45:08 +11:00
|
|
|
program movebloubs
|
|
|
|
|
|
|
|
use bloubspace
|
|
|
|
use povstuff
|
2022-02-09 04:56:51 +11:00
|
|
|
use mathstuff
|
2022-02-07 09:45:08 +11:00
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
character(200) :: infile, outfile
|
|
|
|
integer :: inu, outu, errcode, i
|
2022-02-09 04:56:51 +11:00
|
|
|
integer :: compteur, killed
|
2022-02-07 09:45:08 +11:00
|
|
|
type(t_bloubs) :: bloub
|
|
|
|
double precision :: bx, by, bz
|
2022-02-09 04:56:51 +11:00
|
|
|
logical :: add_new_bloub = .TRUE.
|
|
|
|
! real :: rnd
|
|
|
|
|
|
|
|
call init_random_seed()
|
2022-02-07 09:45:08 +11:00
|
|
|
|
|
|
|
i = IARGC()
|
|
|
|
if (i .ne. 2) then
|
|
|
|
STOP ": BAD ARGS ON COMMAND LINE"
|
|
|
|
endif
|
|
|
|
call getarg(1, infile)
|
|
|
|
call getarg(2, outfile)
|
|
|
|
|
|
|
|
write (0, '(A)') &
|
|
|
|
"*** moving bloubs from "//trim(infile)//" to "//trim(outfile)
|
|
|
|
|
2022-02-09 04:56:51 +11:00
|
|
|
open(newunit=inu, &
|
|
|
|
file=trim(infile), form='unformatted', &
|
2022-02-07 09:45:08 +11:00
|
|
|
iostat=errcode, &
|
|
|
|
action='read', status='old')
|
|
|
|
if (0 .ne. errcode) then
|
|
|
|
STOP " : CAN'T OPEN FILE " // trim(infile)
|
|
|
|
endif
|
|
|
|
|
2022-02-09 04:56:51 +11:00
|
|
|
open(newunit=outu, &
|
|
|
|
file=trim(outfile), form='unformatted', &
|
|
|
|
iostat=errcode, &
|
2022-02-07 09:45:08 +11:00
|
|
|
action='write', status='replace')
|
|
|
|
if (0 .ne. errcode) then
|
2022-02-08 12:53:49 +11:00
|
|
|
STOP " : CAN'T OPEN " // trim(outfile) // "FOR WRITE"
|
2022-02-07 09:45:08 +11:00
|
|
|
endif
|
|
|
|
|
|
|
|
bx = 0.0; by = 0.0; bz = 0.0
|
2022-02-09 04:56:51 +11:00
|
|
|
compteur = 0
|
|
|
|
killed = 0
|
2022-02-07 09:45:08 +11:00
|
|
|
|
|
|
|
do
|
|
|
|
read (unit=inu, iostat=errcode) bloub
|
|
|
|
if (0 .ne. errcode) then
|
2022-02-09 04:56:51 +11:00
|
|
|
! may be we got an EOF ?
|
2022-02-07 09:45:08 +11:00
|
|
|
exit
|
|
|
|
endif
|
|
|
|
|
2022-02-08 12:53:49 +11:00
|
|
|
! moving and boundingboxing
|
2022-02-09 04:56:51 +11:00
|
|
|
call move_bloub (bloub, 0.15)
|
|
|
|
call bound_a_blob (bloub)
|
|
|
|
call green_soylent (bloub)
|
|
|
|
if (.NOT. bloub%alive) then
|
2022-02-09 10:42:32 +11:00
|
|
|
! write(0, '(A)') " KILL!"
|
2022-02-09 04:56:51 +11:00
|
|
|
killed = killed + 1
|
|
|
|
cycle
|
|
|
|
endif
|
2022-02-08 12:53:49 +11:00
|
|
|
! calcul du barycentre
|
2022-02-09 04:56:51 +11:00
|
|
|
bx = bx + dble(bloub%px)
|
|
|
|
by = by + dble(bloub%py)
|
|
|
|
bz = bz + dble(bloub%pz)
|
2022-02-07 09:45:08 +11:00
|
|
|
|
2022-02-08 12:53:49 +11:00
|
|
|
write(outu, iostat=errcode) bloub ! no error control ?
|
|
|
|
if (0 .ne. errcode) then
|
|
|
|
STOP " : WRITE ERROR TO " // trim(outfile)
|
2022-02-07 12:08:17 +11:00
|
|
|
endif
|
2022-02-09 04:56:51 +11:00
|
|
|
compteur = compteur + 1
|
2022-02-07 09:45:08 +11:00
|
|
|
|
|
|
|
enddo
|
|
|
|
|
2022-02-08 12:53:49 +11:00
|
|
|
if (add_new_bloub) then
|
|
|
|
! and now, we inject a new bloub in the universe
|
|
|
|
bloub%nick = 'newbie '
|
|
|
|
bloub%alive = .TRUE.
|
|
|
|
call random_pv(bloub)
|
2022-02-09 04:56:51 +11:00
|
|
|
bloub%radius = 0.045
|
2022-02-08 12:53:49 +11:00
|
|
|
bloub%seq = 0
|
2022-02-09 04:56:51 +11:00
|
|
|
|
2022-02-08 12:53:49 +11:00
|
|
|
call display_bloub (bloub, "new bloub")
|
|
|
|
write(outu) bloub ! no error control ?
|
|
|
|
endif
|
2022-02-07 09:45:08 +11:00
|
|
|
|
|
|
|
close(inu) ; close(outu)
|
|
|
|
|
2022-02-09 10:42:32 +11:00
|
|
|
if (killed .GT. 0) then
|
|
|
|
write (0, '(I5, A)') killed, " bloubs killed"
|
|
|
|
endif
|
|
|
|
|
2022-02-09 04:56:51 +11:00
|
|
|
bx = bx / dble(compteur)
|
|
|
|
by = by / dble(compteur)
|
|
|
|
bz = bz / dble(compteur)
|
|
|
|
write (0, '(A,3(F12.6,3X))') "barycentre : ", bx, by, bz
|
|
|
|
|
|
|
|
|
2022-02-07 09:45:08 +11:00
|
|
|
end program
|