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-17 01:59:42 +11:00
|
|
|
! logical :: add_new_bloub = .TRUE.
|
2022-02-19 05:30:10 +11:00
|
|
|
real :: rnd
|
2022-02-09 04:56:51 +11:00
|
|
|
|
|
|
|
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)') &
|
2022-03-26 08:42:15 +11:00
|
|
|
"### moving bloubs from "//trim(infile)//" to "//trim(outfile)
|
2022-02-07 09:45:08 +11:00
|
|
|
|
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
|
|
|
|
|
2022-03-18 22:21:40 +11:00
|
|
|
! write(0, '("Units: ", 2I5)') inu, outu
|
|
|
|
|
2022-02-07 09:45:08 +11:00
|
|
|
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
|
|
|
|
2024-01-29 15:25:08 +11:00
|
|
|
!-
|
|
|
|
! begin of bigloop
|
|
|
|
!-
|
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-03-18 22:21:40 +11:00
|
|
|
! moving, morphing and boundingboxing
|
2022-03-26 08:42:15 +11:00
|
|
|
call move_bloub (bloub, 0.185)
|
|
|
|
call bound_a_bloub (bloub)
|
|
|
|
if (bloub%radius .GT. 0.0238) then
|
2024-01-29 15:25:08 +11:00
|
|
|
bloub%radius = bloub%radius * 0.999
|
2022-02-19 05:30:10 +11:00
|
|
|
endif
|
2022-03-18 22:21:40 +11:00
|
|
|
|
2024-01-29 15:25:08 +11:00
|
|
|
! XXX call green_soylent (bloub)
|
|
|
|
! XXX if (.NOT. bloub%alive) then
|
|
|
|
! XXX ! write(0, '(A)') " KILL!"
|
|
|
|
! XXX killed = killed + 1
|
|
|
|
! XXX endif
|
2022-03-18 22:21:40 +11:00
|
|
|
|
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-03-26 08:42:15 +11:00
|
|
|
if (bloub%alive) then
|
|
|
|
write(outu, iostat=errcode) bloub
|
|
|
|
if (0 .ne. errcode) then
|
|
|
|
STOP " : WRITE ERROR TO " // trim(outfile)
|
|
|
|
endif
|
|
|
|
compteur = compteur + 1
|
2022-02-07 12:08:17 +11:00
|
|
|
endif
|
2022-02-07 09:45:08 +11:00
|
|
|
|
2022-02-19 05:30:10 +11:00
|
|
|
enddo ! end of main loop
|
|
|
|
|
2024-01-26 07:44:49 +11:00
|
|
|
write(0, '(1X,I0,1X,A)') compteur, "bloubs processed"
|
2024-01-29 15:25:08 +11:00
|
|
|
if (killed .GT. 0) then
|
|
|
|
write (0, '(1X,I0,A)') killed, " bloubs killed"
|
|
|
|
endif
|
2022-02-07 09:45:08 +11:00
|
|
|
|
2024-01-29 15:25:08 +11:00
|
|
|
! ok, we have read all the bloubs from the input file
|
2022-02-12 01:26:52 +11:00
|
|
|
|
|
|
|
! insert some fancy conditional here
|
2022-03-19 09:41:42 +11:00
|
|
|
if (compteur .LT. 200) then
|
2024-01-29 15:25:08 +11:00
|
|
|
call add_more_bloubs(outu, 5, 0.032)
|
2022-02-08 12:53:49 +11:00
|
|
|
endif
|
2022-02-07 09:45:08 +11:00
|
|
|
|
|
|
|
close(inu) ; close(outu)
|
|
|
|
|
2022-02-12 01:26:52 +11:00
|
|
|
! --------------------------------------------------------------
|
|
|
|
contains
|
|
|
|
|
2022-03-18 22:21:40 +11:00
|
|
|
subroutine add_more_bloubs(un, nbre, rayon)
|
2022-02-12 01:26:52 +11:00
|
|
|
integer, intent(in) :: un, nbre
|
2022-03-18 22:21:40 +11:00
|
|
|
real, intent(in) :: rayon
|
2022-02-12 01:26:52 +11:00
|
|
|
type(t_bloubs) :: bloub
|
2022-03-18 22:21:40 +11:00
|
|
|
integer :: foo, count
|
2022-02-12 01:26:52 +11:00
|
|
|
|
2024-01-29 15:25:08 +11:00
|
|
|
count = nbre+mod(irand(), 3)
|
|
|
|
write(0, '(A,I4,1X,A)') "movebloubs adding", count, "bloubs"
|
2022-02-18 00:10:15 +11:00
|
|
|
|
2022-03-18 22:21:40 +11:00
|
|
|
do foo=1, count
|
2022-02-12 01:26:52 +11:00
|
|
|
|
|
|
|
bloub%nick = 'newbie '
|
2024-01-29 15:25:08 +11:00
|
|
|
call make_a_random_bloub(bloub, 7.12)
|
|
|
|
bloub%radius = rayon + (0.09*rand())
|
2022-02-18 00:10:15 +11:00
|
|
|
bloub%age = 1
|
|
|
|
bloub%alive = .TRUE.
|
2022-03-18 22:21:40 +11:00
|
|
|
bloub%num = mod(irand(), 42)
|
2022-02-12 01:26:52 +11:00
|
|
|
write(un) bloub ! no error control ?
|
|
|
|
|
|
|
|
enddo
|
|
|
|
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
! --------------------------------------------------------------
|
2022-02-09 04:56:51 +11:00
|
|
|
|
2022-02-12 01:26:52 +11:00
|
|
|
end program movebloubs
|