Compare commits

...

3 Commits

Author SHA1 Message Date
tTh
7a6e5f1e27 fine tuning 2022-12-11 09:25:23 +01:00
tTh
0abf66fad5 add a gnuplot/shell script 2022-12-06 02:38:41 +01:00
tTh
cc71a55ccb trials.f90: buffering is good for the planet 2022-12-06 01:49:45 +01:00
9 changed files with 141 additions and 18 deletions

View File

@ -6,7 +6,10 @@ WS/*.pgm
WS/*.png
WS/*/*.pgm
WS/*/*.png
WS/*/*.gif
WS/data/*
*.png
*.gif
*.log
*.mp4

View File

@ -18,6 +18,10 @@ passer per une recompilation.
Vous vous en doutez, c'est du POVray.
## Sortie graphique
Actuellement, un script pour enrober gnuplot, what else ?
## Conclusion
Enjoy !

View File

@ -12,13 +12,13 @@ program animation
! some configuration constants
integer, parameter :: S_WIDTH = 1024
integer, parameter :: S_HEIGHT = 1024
integer, parameter :: NB_BODY = 82
integer, parameter :: NB_BODY = 70
!!! WARNING : global variables !!!
!!! WARNING : global variable !!!
type(massbody) :: planets(NB_BODY)
call init_random()
call create_some_planets(planets, 1337e3, S_WIDTH , S_HEIGHT)
call create_some_planets(planets, 1664e3, S_WIDTH , S_HEIGHT)
call print_barycentre_bodies(planets)
! STOP 'BEFORE CRASH'
@ -47,6 +47,10 @@ subroutine la_grande_boucle(start, nbre, moons)
write (filename, "(a, i5.5, a)") 'WS/nanim/', pass, '.pgm'
write(0, '(3I5, " * ", a20)') start, nbre, pass, filename
call build_and_write_a_field(S_WIDTH, S_HEIGHT, moons, filename)
write (filename, "(a, i5.5, a)") 'WS/data/', pass, '.txt'
call save_bodies_to_txt_file (planets, filename)
enddo
call print_barycentre_bodies(moons)
@ -96,7 +100,7 @@ subroutine deplace_les_planetes(moons, clipit)
if (moons(foo)%posy .LT. EE) moons(foo)%posy = SH
endif
moons(foo)%heading = moons(foo)%heading + (0.25*(rand()-0.499999))
moons(foo)%heading = moons(foo)%heading + (0.71*(rand()-0.50))
if (moons(foo)%heading .GT. 6.2831853) moons(foo)%heading = 0.0
if (moons(foo)%heading .LT. 0.0000001) moons(foo)%heading = 0.0

42
GravityField/plotation.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
set -e
SRC=WS/data/00013.txt
DST=graph.png
rm WS/graph/*.png
# ----------------------------------------------------------
plot_a_map ()
{
NUMERO=$1
SRC=$(printf "WS/data/%05d.txt" $NUMERO)
DST=$(printf "WS/graph/%05d.png" $NUMERO)
TXT=$(printf "Mass bodies #%05d" $NUMERO)
echo " " $SRC $DST " " $TXT
gnuplot << __EOC__
set term png size 512,512
set xrange [ 0.0 : 1024 ]
set yrange [ 0.0 : 1024 ]
set output "${DST}"
set ytics 256
set xtics 256
set grid front
set title "${TXT}"
plot "$SRC" using 1:2 title "location"
__EOC__
}
# ----------------------------------------------------------
for foo in $(seq 0 8 1999)
do
plot_a_map $foo
done
convert -delay 10 WS/graph/0????.png foo.gif
# ----------------------------------------------------------

View File

@ -4,15 +4,21 @@
# Makefile for the general purpose moduls
#
GFOPT = -Wall -Wextra -time -g -O
GFOPT = -Wall -Wextra -time -g
all: chkpixels
spitpgm.o: spitpgm.f90 Makefile
gfortran $(GFOPT) -c $< -o $@
trials.o: trials.f90 Makefile
gfortran $(GFOPT) -c $< -o $@
#
# programmes de testouille
#
chkpixels: chkpixels.f90 Makefile spitpgm.o
gfortran $(GFOPT) $< spitpgm.o -o $@
chkpixels: chkpixels.f90 Makefile trials.o spitpgm.o
gfortran $(GFOPT) $< spitpgm.o trials.o -o $@

View File

@ -1,4 +1,10 @@
# General purpose modules
* spitpgm
## spitpgm
Write gray level 2d buffer (aka picture) to disk in the NetPNM format.
## trials
Experimental WIPs from hell.

View File

@ -1,20 +1,25 @@
!-------------------------------------------------------------------
!-
program chkpixels
use spitpgm
use spitpgm ! main module
use trials ! experiments, ymmv.
implicit none
write(0, *) "------ CHKPIXELS ------"
call test_alpha()
call test_alpha(3)
STOP 'BECAUSE NO CPU AVAILABLE'
contains
!-------------------------------------------------------------------
!-
subroutine test_alpha()
subroutine test_alpha(increment)
integer, intent(in) :: increment
integer, parameter :: SZ = 32
integer, parameter :: SZ = 40
integer, dimension(SZ, SZ) :: greymap
integer :: ix, iy, value
@ -22,12 +27,14 @@ contains
do iy=1, SZ
do ix=1, SZ
greymap(ix, iy) = value
value = value + 1
value = value + increment
enddo
enddo
call spit_as_pgm_16 (greymap, 'a.pgm')
call spit_as_pgm_eq (greymap, 'b.pgm')
call spit_as_pgm_8 (greymap, 'c.pgm')
call new_spit_a (greymap, 'x.pgm')
end subroutine

View File

@ -8,8 +8,9 @@ module spitpgm
!-------------------------------------------------------------------
!-
! This subroutine try to scale the values to fit the 16 bit range
!
! This subroutine try to scale the values to fit the 16 bit range.
! XXX may be add a third parameter : the max value required ?
!-
subroutine spit_as_pgm_eq(pic, fname)
integer, intent(in), dimension (:,:) :: pic
@ -19,7 +20,7 @@ subroutine spit_as_pgm_eq(pic, fname)
integer :: ix, iy
real :: fk, fpix
write(0, '(1X, A)') "> spit_as_pgm_eq to " // trim(fname)
! write(0, '(1X, A)') " spit_as_pgm_eq to " // trim(fname)
open(newunit=io, file=fname)
write (io, '(a2)') "P2"
@ -34,7 +35,7 @@ subroutine spit_as_pgm_eq(pic, fname)
enddo
else
fk = float(foo) / 65535.01
write (0, *) " max pix value", foo, " fk ", fk
! write (0, *) " max pix value", foo, " fk ", fk
do iy = 1, ubound(pic, 2)
do ix = 1, ubound(pic, 1)
fpix = float(pic(ix, iy)) / fk
@ -48,6 +49,7 @@ end subroutine
!-------------------------------------------------------------------
!-
! 16 bits - 65535 levels portable grey map file
! no data conversion except upper clippin.
!-
subroutine spit_as_pgm_16(pic, fname)
integer, intent(in), dimension (:,:) :: pic

49
Modules/trials.f90 Normal file
View File

@ -0,0 +1,49 @@
!-
! This module try to write PNM complient files - ymmv
!-
module trials
implicit none
contains
!-------------------------------------------------------------------
subroutine new_spit_a(pic, fname)
integer, intent(in), dimension (:,:) :: pic
character (len=*), intent(in) :: fname
integer :: foo, io, ix, iy
integer :: buffer(8), ptr
! print *, "newspit a, largeur ", size(pic, 1), ubound(pic, 1)
! print *, "newspit a, hauteur ", size(pic, 2), ubound(pic, 2)
! print *, "newspit a, buffer ", size(buffer, 1)
open(newunit=io, file=fname)
write (io, '(a2)') "P2"
write (io, '("# new_spit_a")')
write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2)
write (io, '(i0)') 65535
buffer = 0
ptr = 1
do iy=1, ubound(pic, 2)
do ix=1, ubound(pic, 1)
foo = pic(ix, iy)
if (foo .GT. 65535) foo = 65535
buffer(ptr) = foo
ptr = ptr + 1
if (ptr .EQ. size(buffer, 1)+1) then
write(io, "(8(' ',i0))") buffer
ptr = 1
endif
enddo
enddo
close(io)
end subroutine
!-------------------------------------------------------------------
end module