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
genbloubs
movebloubs
mergebloubs

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@ program movebloubs
integer :: compteur, killed
type(t_bloubs) :: bloub
double precision :: bx, by, bz
logical :: add_new_bloub = .TRUE.
! logical :: add_new_bloub = .TRUE.
! real :: rnd
call init_random_seed()
@ -78,9 +78,9 @@ program movebloubs
! ok, we have read all the bloubs in the input file
! 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
@ -111,7 +111,7 @@ contains
call random_pv(bloub)
bloub%radius = wtf
bloub%seq = foo
call display_bloub (bloub, "new bloub")
! call display_bloub (bloub, "new bloub")
write(un) bloub ! no error control ?
enddo

View File

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