Compare commits
3 Commits
0d0f794103
...
845a00d476
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
845a00d476 | ||
|
|
c1694dbaf2 | ||
|
|
996cf35f35 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,4 +8,5 @@
|
||||
|
||||
spirale
|
||||
starfield
|
||||
randomwalk
|
||||
|
||||
|
||||
3
Makefile
3
Makefile
@@ -11,6 +11,9 @@ genplotting.o: genplotting.f90 Makefile
|
||||
starfield: starfield.f90 Makefile genplotting.o
|
||||
gfortran -Wall $< genplotting.o -o $@
|
||||
|
||||
randomwalk: randomwalk.f90 Makefile genplotting.o
|
||||
gfortran -Wall $< genplotting.o -o $@
|
||||
|
||||
# -----------------------------------------------
|
||||
|
||||
spirale: spirale.f90 Makefile genplotting.o
|
||||
|
||||
@@ -64,6 +64,12 @@ subroutine genp_draw (px, py, color)
|
||||
if (ly .gt. ymax) ymax = ly
|
||||
end subroutine
|
||||
! ---------------------------------------------------------
|
||||
subroutine genp_line(xa, ya, xb, yb, color)
|
||||
real, intent(in) :: xa, ya, xb, yb
|
||||
integer, intent(in) :: color
|
||||
call genp_move(xa, ya)
|
||||
call genp_draw(xb, yb, color)
|
||||
end subroutine
|
||||
! ---------------------------------------------------------
|
||||
subroutine genp_end (foo)
|
||||
integer, intent(in) :: foo
|
||||
|
||||
36
randomwalk.f90
Normal file
36
randomwalk.f90
Normal file
@@ -0,0 +1,36 @@
|
||||
!
|
||||
! R A N D O M W A L K
|
||||
! la marche de l'ivrogne qui cherche ses clefs sous
|
||||
! le lampadaire, juste là où il y a de la lumière.
|
||||
!
|
||||
program randomwalk
|
||||
use genplotting
|
||||
implicit none
|
||||
integer foo, col
|
||||
|
||||
write (0, '(A)') "----[ genplotting randomwalk ]----"
|
||||
call srand(time())
|
||||
call genp_init (0, 'randomwalk.scratch')
|
||||
do foo=1, 51
|
||||
col = 2 + mod(foo, 4)
|
||||
call do_randomwalk(42, col)
|
||||
enddo
|
||||
call genp_end (0)
|
||||
contains
|
||||
! ---------------------------------------------------------
|
||||
subroutine do_randomwalk(nbre, col)
|
||||
integer, intent(in) :: nbre, col
|
||||
integer :: idx
|
||||
real :: px, py, px2, py2
|
||||
|
||||
px = 0.0 ; py = 0.0
|
||||
call genp_move(px, py)
|
||||
do idx=1, nbre
|
||||
px2 = px + rand(0) - 0.50
|
||||
py2 = py + rand(0) - 0.50
|
||||
call genp_line(px, py, px2, py2, col)
|
||||
px = px2 ; py = py2
|
||||
enddo
|
||||
end subroutine
|
||||
! ---------------------------------------------------------
|
||||
end program
|
||||
@@ -29,7 +29,7 @@ subroutine do_starfield (nbstar)
|
||||
integer, intent(in) :: nbstar
|
||||
integer idx, color
|
||||
real px, py, sz
|
||||
do idx=0, nbstar
|
||||
do idx=1, nbstar
|
||||
px = (rand(0) * 10.00) - 5.00
|
||||
py = (rand(0) * 10.00) - 5.00
|
||||
sz = (rand(0) * 0.16) + 0.16
|
||||
|
||||
Reference in New Issue
Block a user