From b26618a841501ded9418cc1daebcd059d2ed0351 Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 16 Feb 2022 15:59:42 +0100 Subject: [PATCH] mergebloubs boilerplate done --- BloubWorld/.gitignore | 1 + BloubWorld/Makefile | 11 ++++++++++- BloubWorld/bloubspace.f90 | 38 ++++++++++++++++++++++++++++---------- BloubWorld/genbloubs.f90 | 9 +++++---- BloubWorld/mathstuff.f90 | 1 + BloubWorld/movebloubs.f90 | 8 ++++---- BloubWorld/runme.sh | 15 +++++++++------ 7 files changed, 58 insertions(+), 25 deletions(-) diff --git a/BloubWorld/.gitignore b/BloubWorld/.gitignore index b431fb1..a8281c6 100644 --- a/BloubWorld/.gitignore +++ b/BloubWorld/.gitignore @@ -11,4 +11,5 @@ log.* exportbloubs genbloubs movebloubs +mergebloubs diff --git a/BloubWorld/Makefile b/BloubWorld/Makefile index e150034..4b50f23 100644 --- a/BloubWorld/Makefile +++ b/BloubWorld/Makefile @@ -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 $@ + # ------------------------------------------------------------ diff --git a/BloubWorld/bloubspace.f90 b/BloubWorld/bloubspace.f90 index 42b05e9..4738154 100644 --- a/BloubWorld/bloubspace.f90 +++ b/BloubWorld/bloubspace.f90 @@ -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 diff --git a/BloubWorld/genbloubs.f90 b/BloubWorld/genbloubs.f90 index 1bf19f8..459fab4 100644 --- a/BloubWorld/genbloubs.f90 +++ b/BloubWorld/genbloubs.f90 @@ -28,11 +28,12 @@ program genbloubs do i = 1, nbbloubs - bloub%nick = 'noname ' - bloub%alive = .TRUE. + bloub%nick = 'noname ' + bloub%num = i + 41 + bloub%alive = .TRUE. call random_pv(bloub) - bloub%radius = 0.025 - bloub%seq = 0 + bloub%radius = 0.025 + bloub%age = 0 write(idu) bloub ! no error control ? diff --git a/BloubWorld/mathstuff.f90 b/BloubWorld/mathstuff.f90 index e45e9b3..f0851ab 100644 --- a/BloubWorld/mathstuff.f90 +++ b/BloubWorld/mathstuff.f90 @@ -5,6 +5,7 @@ module mathstuff contains ! ---------------------------------------------------------------- + ! really quick'n'dirty hack subroutine init_random_seed() diff --git a/BloubWorld/movebloubs.f90 b/BloubWorld/movebloubs.f90 index 2468504..10ebb5f 100644 --- a/BloubWorld/movebloubs.f90 +++ b/BloubWorld/movebloubs.f90 @@ -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 diff --git a/BloubWorld/runme.sh b/BloubWorld/runme.sh index dd05743..f3753fe 100755 --- a/BloubWorld/runme.sh +++ b/BloubWorld/runme.sh @@ -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