Compare commits
3 Commits
5b6df523fc
...
7a6e5f1e27
Author | SHA1 | Date | |
---|---|---|---|
|
7a6e5f1e27 | ||
|
0abf66fad5 | ||
|
cc71a55ccb |
3
GravityField/.gitignore
vendored
3
GravityField/.gitignore
vendored
@ -6,7 +6,10 @@ WS/*.pgm
|
|||||||
WS/*.png
|
WS/*.png
|
||||||
WS/*/*.pgm
|
WS/*/*.pgm
|
||||||
WS/*/*.png
|
WS/*/*.png
|
||||||
|
WS/*/*.gif
|
||||||
|
WS/data/*
|
||||||
|
|
||||||
|
*.png
|
||||||
*.gif
|
*.gif
|
||||||
*.log
|
*.log
|
||||||
*.mp4
|
*.mp4
|
||||||
|
@ -18,6 +18,10 @@ passer per une recompilation.
|
|||||||
|
|
||||||
Vous vous en doutez, c'est du POVray.
|
Vous vous en doutez, c'est du POVray.
|
||||||
|
|
||||||
|
## Sortie graphique
|
||||||
|
|
||||||
|
Actuellement, un script pour enrober gnuplot, what else ?
|
||||||
|
|
||||||
## Conclusion
|
## Conclusion
|
||||||
|
|
||||||
Enjoy !
|
Enjoy !
|
||||||
|
@ -12,13 +12,13 @@ program animation
|
|||||||
! some configuration constants
|
! some configuration constants
|
||||||
integer, parameter :: S_WIDTH = 1024
|
integer, parameter :: S_WIDTH = 1024
|
||||||
integer, parameter :: S_HEIGHT = 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)
|
type(massbody) :: planets(NB_BODY)
|
||||||
|
|
||||||
call init_random()
|
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)
|
call print_barycentre_bodies(planets)
|
||||||
|
|
||||||
! STOP 'BEFORE CRASH'
|
! 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 (filename, "(a, i5.5, a)") 'WS/nanim/', pass, '.pgm'
|
||||||
write(0, '(3I5, " * ", a20)') start, nbre, pass, filename
|
write(0, '(3I5, " * ", a20)') start, nbre, pass, filename
|
||||||
call build_and_write_a_field(S_WIDTH, S_HEIGHT, moons, 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
|
enddo
|
||||||
|
|
||||||
call print_barycentre_bodies(moons)
|
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
|
if (moons(foo)%posy .LT. EE) moons(foo)%posy = SH
|
||||||
endif
|
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 .GT. 6.2831853) moons(foo)%heading = 0.0
|
||||||
if (moons(foo)%heading .LT. 0.0000001) moons(foo)%heading = 0.0
|
if (moons(foo)%heading .LT. 0.0000001) moons(foo)%heading = 0.0
|
||||||
|
|
||||||
|
42
GravityField/plotation.sh
Executable file
42
GravityField/plotation.sh
Executable 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
|
||||||
|
|
||||||
|
# ----------------------------------------------------------
|
@ -4,15 +4,21 @@
|
|||||||
# Makefile for the general purpose moduls
|
# Makefile for the general purpose moduls
|
||||||
#
|
#
|
||||||
|
|
||||||
GFOPT = -Wall -Wextra -time -g -O
|
GFOPT = -Wall -Wextra -time -g
|
||||||
|
|
||||||
|
all: chkpixels
|
||||||
|
|
||||||
|
|
||||||
spitpgm.o: spitpgm.f90 Makefile
|
spitpgm.o: spitpgm.f90 Makefile
|
||||||
gfortran $(GFOPT) -c $< -o $@
|
gfortran $(GFOPT) -c $< -o $@
|
||||||
|
|
||||||
|
trials.o: trials.f90 Makefile
|
||||||
|
gfortran $(GFOPT) -c $< -o $@
|
||||||
|
|
||||||
#
|
#
|
||||||
# programmes de testouille
|
# programmes de testouille
|
||||||
#
|
#
|
||||||
|
|
||||||
chkpixels: chkpixels.f90 Makefile spitpgm.o
|
chkpixels: chkpixels.f90 Makefile trials.o spitpgm.o
|
||||||
gfortran $(GFOPT) $< spitpgm.o -o $@
|
gfortran $(GFOPT) $< spitpgm.o trials.o -o $@
|
||||||
|
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
# General purpose modules
|
# General purpose modules
|
||||||
|
|
||||||
|
|
||||||
* spitpgm
|
## spitpgm
|
||||||
|
|
||||||
|
Write gray level 2d buffer (aka picture) to disk in the NetPNM format.
|
||||||
|
|
||||||
|
## trials
|
||||||
|
|
||||||
|
Experimental WIPs from hell.
|
||||||
|
@ -1,20 +1,25 @@
|
|||||||
|
!-------------------------------------------------------------------
|
||||||
|
!-
|
||||||
|
|
||||||
program chkpixels
|
program chkpixels
|
||||||
|
|
||||||
use spitpgm
|
use spitpgm ! main module
|
||||||
|
use trials ! experiments, ymmv.
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
|
|
||||||
write(0, *) "------ CHKPIXELS ------"
|
write(0, *) "------ CHKPIXELS ------"
|
||||||
call test_alpha()
|
call test_alpha(3)
|
||||||
|
|
||||||
STOP 'BECAUSE NO CPU AVAILABLE'
|
STOP 'BECAUSE NO CPU AVAILABLE'
|
||||||
|
|
||||||
contains
|
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, dimension(SZ, SZ) :: greymap
|
||||||
integer :: ix, iy, value
|
integer :: ix, iy, value
|
||||||
|
|
||||||
@ -22,12 +27,14 @@ contains
|
|||||||
do iy=1, SZ
|
do iy=1, SZ
|
||||||
do ix=1, SZ
|
do ix=1, SZ
|
||||||
greymap(ix, iy) = value
|
greymap(ix, iy) = value
|
||||||
value = value + 1
|
value = value + increment
|
||||||
enddo
|
enddo
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
call spit_as_pgm_16 (greymap, 'a.pgm')
|
call spit_as_pgm_16 (greymap, 'a.pgm')
|
||||||
call spit_as_pgm_eq (greymap, 'b.pgm')
|
call spit_as_pgm_eq (greymap, 'b.pgm')
|
||||||
call spit_as_pgm_8 (greymap, 'c.pgm')
|
call spit_as_pgm_8 (greymap, 'c.pgm')
|
||||||
|
call new_spit_a (greymap, 'x.pgm')
|
||||||
|
|
||||||
end subroutine
|
end subroutine
|
||||||
|
|
||||||
|
@ -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)
|
subroutine spit_as_pgm_eq(pic, fname)
|
||||||
|
|
||||||
integer, intent(in), dimension (:,:) :: pic
|
integer, intent(in), dimension (:,:) :: pic
|
||||||
@ -19,7 +20,7 @@ subroutine spit_as_pgm_eq(pic, fname)
|
|||||||
integer :: ix, iy
|
integer :: ix, iy
|
||||||
real :: fk, fpix
|
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)
|
open(newunit=io, file=fname)
|
||||||
write (io, '(a2)') "P2"
|
write (io, '(a2)') "P2"
|
||||||
@ -34,7 +35,7 @@ subroutine spit_as_pgm_eq(pic, fname)
|
|||||||
enddo
|
enddo
|
||||||
else
|
else
|
||||||
fk = float(foo) / 65535.01
|
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 iy = 1, ubound(pic, 2)
|
||||||
do ix = 1, ubound(pic, 1)
|
do ix = 1, ubound(pic, 1)
|
||||||
fpix = float(pic(ix, iy)) / fk
|
fpix = float(pic(ix, iy)) / fk
|
||||||
@ -48,6 +49,7 @@ end subroutine
|
|||||||
!-------------------------------------------------------------------
|
!-------------------------------------------------------------------
|
||||||
!-
|
!-
|
||||||
! 16 bits - 65535 levels portable grey map file
|
! 16 bits - 65535 levels portable grey map file
|
||||||
|
! no data conversion except upper clippin.
|
||||||
!-
|
!-
|
||||||
subroutine spit_as_pgm_16(pic, fname)
|
subroutine spit_as_pgm_16(pic, fname)
|
||||||
integer, intent(in), dimension (:,:) :: pic
|
integer, intent(in), dimension (:,:) :: pic
|
||||||
|
49
Modules/trials.f90
Normal file
49
Modules/trials.f90
Normal 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
|
Loading…
Reference in New Issue
Block a user