subroutine green_soylent in actio
This commit is contained in:
@@ -2,14 +2,19 @@ program movebloubs
|
||||
|
||||
use bloubspace
|
||||
use povstuff
|
||||
use mathstuff
|
||||
|
||||
implicit none
|
||||
|
||||
character(200) :: infile, outfile
|
||||
integer :: inu, outu, errcode, i
|
||||
integer :: compteur, killed
|
||||
type(t_bloubs) :: bloub
|
||||
double precision :: bx, by, bz
|
||||
logical :: add_new_bloub = .FALSE.
|
||||
logical :: add_new_bloub = .TRUE.
|
||||
! real :: rnd
|
||||
|
||||
call init_random_seed()
|
||||
|
||||
i = IARGC()
|
||||
if (i .ne. 2) then
|
||||
@@ -18,46 +23,55 @@ program movebloubs
|
||||
call getarg(1, infile)
|
||||
call getarg(2, outfile)
|
||||
|
||||
inu = 42 ; outu = 51
|
||||
|
||||
write (0, '(A)') &
|
||||
"*** moving bloubs from "//trim(infile)//" to "//trim(outfile)
|
||||
|
||||
open(unit=inu, file=trim(infile), form='unformatted', &
|
||||
open(newunit=inu, &
|
||||
file=trim(infile), form='unformatted', &
|
||||
iostat=errcode, &
|
||||
action='read', status='old')
|
||||
if (0 .ne. errcode) then
|
||||
STOP " : CAN'T OPEN FILE " // trim(infile)
|
||||
endif
|
||||
|
||||
open(unit=outu, file=trim(outfile), form='unformatted', &
|
||||
iostat=errcode, &
|
||||
open(newunit=outu, &
|
||||
file=trim(outfile), form='unformatted', &
|
||||
iostat=errcode, &
|
||||
action='write', status='replace')
|
||||
if (0 .ne. errcode) then
|
||||
STOP " : CAN'T OPEN " // trim(outfile) // "FOR WRITE"
|
||||
endif
|
||||
|
||||
bx = 0.0; by = 0.0; bz = 0.0
|
||||
compteur = 0
|
||||
killed = 0
|
||||
|
||||
do
|
||||
read (unit=inu, iostat=errcode) bloub
|
||||
if (0 .ne. errcode) then
|
||||
! may be we got an EOF ?
|
||||
exit
|
||||
endif
|
||||
|
||||
! moving and boundingboxing
|
||||
call move_bloub (bloub, 0.11)
|
||||
call bound_a_blob(bloub)
|
||||
|
||||
call move_bloub (bloub, 0.15)
|
||||
call bound_a_blob (bloub)
|
||||
call green_soylent (bloub)
|
||||
if (.NOT. bloub%alive) then
|
||||
write(0, '(A)') " KILL!"
|
||||
killed = killed + 1
|
||||
cycle
|
||||
endif
|
||||
! calcul du barycentre
|
||||
bx = bx + bloub%px
|
||||
by = by + bloub%py
|
||||
bz = bz + bloub%pz
|
||||
bx = bx + dble(bloub%px)
|
||||
by = by + dble(bloub%py)
|
||||
bz = bz + dble(bloub%pz)
|
||||
|
||||
write(outu, iostat=errcode) bloub ! no error control ?
|
||||
if (0 .ne. errcode) then
|
||||
STOP " : WRITE ERROR TO " // trim(outfile)
|
||||
endif
|
||||
compteur = compteur + 1
|
||||
|
||||
enddo
|
||||
|
||||
@@ -66,19 +80,20 @@ program movebloubs
|
||||
bloub%nick = 'newbie '
|
||||
bloub%alive = .TRUE.
|
||||
call random_pv(bloub)
|
||||
bloub%radius = 0.042
|
||||
bloub%radius = 0.045
|
||||
bloub%seq = 0
|
||||
!
|
||||
! where is the bug ?
|
||||
!
|
||||
|
||||
call display_bloub (bloub, "new bloub")
|
||||
write(outu) bloub ! no error control ?
|
||||
endif
|
||||
|
||||
! ther was some strange bias in this data
|
||||
! may be a random not symetric around 0.0 ?
|
||||
write (0, '(A,3(F11.3,3X))') "barycentre : ", bx, by, bz
|
||||
|
||||
close(inu) ; close(outu)
|
||||
|
||||
write (0, '(I5, A)') killed, " bloubs killed"
|
||||
bx = bx / dble(compteur)
|
||||
by = by / dble(compteur)
|
||||
bz = bz / dble(compteur)
|
||||
write (0, '(A,3(F12.6,3X))') "barycentre : ", bx, by, bz
|
||||
|
||||
|
||||
end program
|
||||
Reference in New Issue
Block a user