first gif89a with fortran & plplot
This commit is contained in:
4
code/fortran/.gitignore
vendored
4
code/fortran/.gitignore
vendored
@@ -3,4 +3,6 @@ plplotting
|
||||
dessiner
|
||||
|
||||
*.png
|
||||
|
||||
*.gif
|
||||
WS/*.png
|
||||
WS/*.eps
|
||||
|
||||
@@ -6,3 +6,9 @@ plplotting: plplotting.f90 Makefile
|
||||
|
||||
dessiner: dessiner.f90 Makefile
|
||||
gfortran -g $< $(INCS) -lplplotfortran -o $@
|
||||
|
||||
|
||||
foo.gif: dessiner Makefile
|
||||
rm -f WS/A????.png
|
||||
./dessiner
|
||||
convert -delay 10 -colors 31 WS/A????.png foo.gif
|
||||
3
code/fortran/WS/README.md
Normal file
3
code/fortran/WS/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Workspace
|
||||
|
||||
This directory must exist if you want to run exemples.
|
||||
@@ -3,35 +3,17 @@ program dessiner
|
||||
implicit none
|
||||
|
||||
integer :: i
|
||||
real :: a, b, c, d
|
||||
|
||||
character(len=80) :: version
|
||||
call plgver(version)
|
||||
write (*,'(a,a)') 'plplot version: ', trim(version)
|
||||
write (*,'(a,a)') 'plPlot version: ', trim(version)
|
||||
|
||||
call plsdev('xwin')
|
||||
call plinit ()
|
||||
|
||||
call plenv(-2.2, 2.2, -2.2, 2.2, 0, 1)
|
||||
|
||||
a = 0
|
||||
b = 0
|
||||
c = 0
|
||||
d = 0
|
||||
do i=1, 100
|
||||
a = a + 0.01
|
||||
b = b + 0.02
|
||||
call dessin_1 (a, b, 12)
|
||||
c = c + 0.03
|
||||
d = d + 0.04
|
||||
call dessin_1 (c, d, 13)
|
||||
enddo
|
||||
|
||||
call plend
|
||||
! call dessin_X11 (0.00, 1.51, 11)
|
||||
call dessin_dans_un_fichier ()
|
||||
|
||||
contains ! -----------------------------
|
||||
!------------------------------------------------------
|
||||
subroutine dessin_1 (sha, shb, color)
|
||||
subroutine dessin_X11 (sha, shb, color)
|
||||
real, intent(in) :: sha, shb
|
||||
integer, intent(in) :: color
|
||||
|
||||
@@ -40,8 +22,13 @@ subroutine dessin_1 (sha, shb, color)
|
||||
real :: k, amp
|
||||
integer :: i
|
||||
|
||||
! print *, 'dessin 1'
|
||||
amp = 2.0
|
||||
print *, 'dessin X11:', sha, shb, color
|
||||
|
||||
call plsdev('xwin')
|
||||
call plinit ()
|
||||
call plenv (-2.1, 2.1, -2.1, 2.1, 1, 2)
|
||||
|
||||
amp = 2.16
|
||||
do i = 1, lg
|
||||
k = real(i)/real(lg) * 6.2832 * 4.0
|
||||
x(i) = amp * sin((k+sha)*5)
|
||||
@@ -54,11 +41,55 @@ subroutine dessin_1 (sha, shb, color)
|
||||
call plcol0 (color)
|
||||
call plline (x, y)
|
||||
|
||||
call plend
|
||||
|
||||
end subroutine
|
||||
!------------------------------------------------------
|
||||
subroutine dessin_2 ()
|
||||
!- _ __ ___ ___ ___
|
||||
!- __ _ (_) / _| ( _ ) / _ \ __ _ |__ \
|
||||
!- / _` | | | | |_ / _ \ | (_) | / _` | / /
|
||||
!- | (_| | | | | _| | (_) | \__, | | (_| | |_|
|
||||
!- \__, | |_| |_| \___/ /_/ \__,_| (_)
|
||||
!- |___/
|
||||
|
||||
subroutine dessin_dans_un_fichier ()
|
||||
|
||||
integer, parameter :: nbpts = 40
|
||||
real :: x(nbpts), y(nbpts)
|
||||
integer :: frame, i
|
||||
character(len=89) :: filename
|
||||
character(len=89) :: buffer
|
||||
character(len=3) :: str
|
||||
|
||||
print *, 'Dessin dans un fichier'
|
||||
|
||||
do i=1, nbpts
|
||||
x(i) = 8.50 * (rand() - 0.5000)
|
||||
y(i) = 8.50 * (rand() - 0.5000)
|
||||
enddo
|
||||
|
||||
do frame= 0, 149
|
||||
write (filename, "(a, i4.4, a)") "WS/A", frame, ".png"
|
||||
print *, frame, ' => ', trim(filename)
|
||||
call plsdev ('pngcairo')
|
||||
call plsfnam (trim(filename))
|
||||
call plinit ()
|
||||
call plenv (-10., 10., -10., 10., 0, 1)
|
||||
call plcol0 (3)
|
||||
do i=1, nbpts
|
||||
x(i) = x(i) + (rand() - 0.5000)
|
||||
y(i) = y(i) + (rand() - 0.5000)
|
||||
call plline (x, y)
|
||||
enddo
|
||||
write(buffer, "(i3.3)") frame
|
||||
str = trim(buffer)
|
||||
call plcol0 (15)
|
||||
call plstring (x, y, buffer)
|
||||
|
||||
call plend
|
||||
enddo
|
||||
|
||||
|
||||
print *, 'dessin 2'
|
||||
|
||||
end subroutine
|
||||
!------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user