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

@ -11,4 +11,5 @@ log.*
exportbloubs exportbloubs
genbloubs genbloubs
movebloubs movebloubs
mergebloubs

View File

@ -1,6 +1,6 @@
all: genbloubs movebloubs exportbloubs all: genbloubs movebloubs exportbloubs mergebloubs
GFOPT = -Wall -Wextra -g -time GFOPT = -Wall -Wextra -g -time
@ -11,6 +11,12 @@ OBJS = bloubspace.o povstuff.o mathstuff.o
initial.blbs: genbloubs Makefile initial.blbs: genbloubs Makefile
./genbloubs $@ 1000 ./genbloubs $@ 1000
in.blbs: genbloubs Makefile
./genbloubs $@ 10000
out.blbs: in.blbs mergebloubs Makefile
./mergebloubs $< $@
# ------------------------------------------------------------ # ------------------------------------------------------------
bloubspace.o: bloubspace.f90 Makefile bloubspace.o: bloubspace.f90 Makefile
@ -33,5 +39,8 @@ movebloubs: movebloubs.f90 Makefile $(OBJS)
exportbloubs: exportbloubs.f90 Makefile $(OBJS) exportbloubs: exportbloubs.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@ gfortran $(GFOPT) $< $(OBJS) -o $@
mergebloubs: mergebloubs.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@
# ------------------------------------------------------------ # ------------------------------------------------------------

View File

@ -15,7 +15,7 @@ module bloubspace
real :: px, py, pz real :: px, py, pz
real :: vx, vy, vz real :: vx, vy, vz
real :: radius real :: radius
integer :: seq integer :: age
end type t_bloubs end type t_bloubs
contains ! ----------------------------------------- contains ! -----------------------------------------
@ -47,8 +47,9 @@ module bloubspace
else else
life = "dead" life = "dead"
endif endif
write (0, '(4X, A)') '+------------ ' // message write (0, '(4X, A)') '+--------------- ' // message // " -------"
write (0, '(4X,A3,A8,2X,I6,4X,A5)') '| ', blb%nick, blb%num, life 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))') '| 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, '(4X,A3,3X,3(F8.3, 4X))') '| V', blb%vx, blb%vy, blb%vz
write (0, '()') write (0, '()')
@ -74,42 +75,59 @@ module bloubspace
if (5.0 .lt. blb%px) then if (5.0 .lt. blb%px) then
blb%vx = -1.0 * blb%vx blb%vx = -1.0 * blb%vx
blb%px = 5.0 blb%px = 5.0
blb%seq = blb%seq + 1 blb%age = blb%age + 1
endif endif
if (-5.0 .gt. blb%px) then if (-5.0 .gt. blb%px) then
blb%vx = -1.0 * blb%vx blb%vx = -1.0 * blb%vx
blb%px = -5.0 blb%px = -5.0
blb%seq = blb%seq + 1 blb%age = blb%age + 1
endif endif
if (0.0 .gt. blb%py) then if (0.0 .gt. blb%py) then
blb%vy = -1.0 * blb%vy blb%vy = -1.0 * blb%vy
blb%py = 0.0 blb%py = 0.0
blb%seq = blb%seq + 1 blb%age = blb%age + 1
endif endif
if (5.0 .lt. blb%py) then if (5.0 .lt. blb%py) then
blb%vy = -1.0 * blb%vy blb%vy = -1.0 * blb%vy
blb%seq = blb%seq + 1 blb%age = blb%age + 1
blb%py = 5.0 blb%py = 5.0
endif endif
if (5.0 .lt. blb%pz) then if (5.0 .lt. blb%pz) then
blb%vz = -1.0 * blb%vz blb%vz = -1.0 * blb%vz
blb%seq = blb%seq + 1 blb%age = blb%age + 1
blb%pz = 5.0 blb%pz = 5.0
endif endif
if (-5.0 .gt. blb%pz) then if (-5.0 .gt. blb%pz) then
blb%vz = -1.0 * blb%vz blb%vz = -1.0 * blb%vz
blb%seq = blb%seq + 1 blb%age = blb%age + 1
blb%pz = -5.0 blb%pz = -5.0
endif endif
end subroutine 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) subroutine green_soylent (blb)
type(t_bloubs), intent (inout) :: blb type(t_bloubs), intent (inout) :: blb
if (blb%seq .gt. 6) then if (blb%age .gt. 5) then
blb%alive = .FALSE. blb%alive = .FALSE.
endif endif
end subroutine end subroutine

View File

@ -29,10 +29,11 @@ program genbloubs
do i = 1, nbbloubs do i = 1, nbbloubs
bloub%nick = 'noname ' bloub%nick = 'noname '
bloub%num = i + 41
bloub%alive = .TRUE. bloub%alive = .TRUE.
call random_pv(bloub) call random_pv(bloub)
bloub%radius = 0.025 bloub%radius = 0.025
bloub%seq = 0 bloub%age = 0
write(idu) bloub ! no error control ? write(idu) bloub ! no error control ?

View File

@ -5,6 +5,7 @@ module mathstuff
contains contains
! ---------------------------------------------------------------- ! ----------------------------------------------------------------
! really quick'n'dirty hack
subroutine init_random_seed() subroutine init_random_seed()

View File

@ -11,7 +11,7 @@ program movebloubs
integer :: compteur, killed integer :: compteur, killed
type(t_bloubs) :: bloub type(t_bloubs) :: bloub
double precision :: bx, by, bz double precision :: bx, by, bz
logical :: add_new_bloub = .TRUE. ! logical :: add_new_bloub = .TRUE.
! real :: rnd ! real :: rnd
call init_random_seed() call init_random_seed()
@ -78,9 +78,9 @@ program movebloubs
! ok, we have read all the bloubs in the input file ! ok, we have read all the bloubs in the input file
! insert some fancy conditional here ! insert some fancy conditional here
if (add_new_bloub) then if (compteur .LT. 1500) then
call add_more_bloubs(outu, 8, 0.095) call add_more_bloubs(outu, 8, 0.075)
endif endif
@ -111,7 +111,7 @@ contains
call random_pv(bloub) call random_pv(bloub)
bloub%radius = wtf bloub%radius = wtf
bloub%seq = foo bloub%seq = foo
call display_bloub (bloub, "new bloub") ! call display_bloub (bloub, "new bloub")
write(un) bloub ! no error control ? write(un) bloub ! no error control ?
enddo enddo

View File

@ -7,14 +7,15 @@
INCFILE="bloubs.inc" INCFILE="bloubs.inc"
TMPPNG="/dev/shm/bloubs7.png" TMPPNG="/dev/shm/bloubs7.png"
POVOPT="+Q9 +a -v -d -W920 -H600 -WT2" POVOPT="+Q5 -a -v -d -W920 -H600 -WT2"
DDIR="frames" DDIR="frames"
LOGERR="log.error" LOGERR="log.error"
# --- put the work file in ramdisk
BLBS_IN="/dev/shm/in.blbs" BLBS_IN="/dev/shm/in.blbs"
BLBS_OUT="/dev/shm/out.blbs" BLBS_OUT="/dev/shm/out.blbs"
NBIMG=4000 NBIMG=600
make all make all
err=$? err=$?
@ -27,9 +28,9 @@ printf "\n#declare NbImg = %d;\n" $NBIMG > nbimg.inc
# #
# first, we have to make a seminal buch of bloubs # first, we have to make a seminal buch of bloubs
# --> this function need to be paraletrizable # --> this function need to be parametrizable
# #
./genbloubs ${BLBS_IN} 5000 ./genbloubs ${BLBS_IN} 100
for idx in $(seq 0 $NBIMG) for idx in $(seq 0 $NBIMG)
do do
@ -53,7 +54,7 @@ do
convert ${TMPPNG} \ convert ${TMPPNG} \
-font Courier-Bold \ -font Courier-Bold \
-pointsize 22 \ -pointsize 22 \
-fill CadetBlue \ -fill Orange \
-gravity south-east \ -gravity south-east \
-annotate +15+10 "$td" \ -annotate +15+10 "$td" \
-gravity south-west \ -gravity south-west \
@ -66,6 +67,8 @@ do
mv ${BLBS_OUT} ${BLBS_IN} mv ${BLBS_OUT} ${BLBS_IN}
echo echo
sleep 33
done done
rm $LOGERR rm $LOGERR
@ -73,6 +76,6 @@ rm $LOGERR
# XXX convert -delay 10 -resize 50% -colors 192 \ # XXX convert -delay 10 -resize 50% -colors 192 \
# XXX $DDIR/????[0]*.png foo.gif # XXX $DDIR/????[0]*.png foo.gif
./encode.sh nice ./encode.sh